[Go to site: main page, start]

0% found this document useful (0 votes)
12 views28 pages

? Java Notes

The document outlines a skill roadmap for aspiring Software Development Engineers (SDEs) at Swiggy, focusing on essential programming languages (Java and Go), backend development concepts, databases, distributed systems, cloud platforms, version control, problem-solving, and soft skills. It provides detailed learning topics, resources, and examples for each area, emphasizing the importance of object-oriented programming principles such as encapsulation, inheritance, abstraction, and polymorphism. The roadmap serves as a comprehensive guide for candidates to prepare for backend development roles effectively.

Uploaded by

Yashika
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views28 pages

? Java Notes

The document outlines a skill roadmap for aspiring Software Development Engineers (SDEs) at Swiggy, focusing on essential programming languages (Java and Go), backend development concepts, databases, distributed systems, cloud platforms, version control, problem-solving, and soft skills. It provides detailed learning topics, resources, and examples for each area, emphasizing the importance of object-oriented programming principles such as encapsulation, inheritance, abstraction, and polymorphism. The roadmap serves as a comprehensive guide for candidates to prepare for backend development roles effectively.

Uploaded by

Yashika
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd

🚀 Skill Roadmap for aSDE (Swiggy Backend)

🧩 1. Programming Fundamentals

Language:

 Java (Primary) — focus on backend + concurrency


 Go (Golang) — optional but great to stand out

Learn in Java:

 OOP concepts (Encapsulation, Inheritance, Polymorphism, Abstraction)


 Collections Framework (List, Map, Set, Queue)
 Exception handling
 Generics
 Streams & Lambda expressions
 Multithreading and Concurrency
 File I/O, Serialization

Learn in Go (optional, for backend microservices):

 Packages and modules


 Goroutines and channels
 Interfaces and error handling
 Building REST APIs using gin or echo

📚 Resources:

 Java: Head First Java, Java Brains YouTube, GeeksforGeeks Java


 Go: Tour of Go (official site), TechWithTim Go tutorials

⚙️2. Backend Development Concepts


Learn how backend systems work, including RESTful APIs, authentication, caching, and
message queues.

Topics to cover:

 REST API design (GET, POST, PUT, DELETE)


 MVC architecture
 JSON, XML serialization
 Authentication: JWT, OAuth
 Caching (Redis / Elasticache)
 API Rate limiting, pagination
 Logging & error handling

📚 Resources:

 “Designing Web APIs” by Brenda Jin


 RESTful API design (YouTube: Fireship or ByteByteGo)

🗃️3. Databases & Data Modeling

You’ll be working with SQL + NoSQL databases.

Learn:

 SQL: Joins, indexing, normalization, transactions


 MySQL/PostgreSQL (Relational DBs)
 DynamoDB / MongoDB (NoSQL concepts)
 Data modeling — entity relationships, schema design

📚 Resources:

 SQLBolt (interactive)
 MongoDB University free courses
 AWS DynamoDB docs for key-value design

🔄 4. Distributed Systems & Tools Mentioned


These are crucial — Swiggy handles millions of transactions per day, so they rely on these:

Tool What to Learn


Elastic Cache (Redis) Caching concepts, TTL, cache invalidation
Elasticsearch Search indexing, queries, analyzers
Kafka Pub/Sub model, partitions, consumer groups
SQS Message queues, producers/consumers
DynamoDB NoSQL data modeling, partition keys, queries

📚 Resources:

 YouTube: Tech Dummies Narendra L (Kafka, Redis, Elasticsearch)


 Blogs: AWS tutorials on SQS, DynamoDB

☁️5. Cloud Platforms (AWS / GCP / Azure)

Since they mentioned familiarity with cloud:

Focus on AWS basics:

 EC2 (compute)
 S3 (storage)
 RDS (database)
 Lambda (serverless)
 IAM (security)
 CloudWatch (monitoring)

📚 Resources:

 AWS Free Tier + AWS Skill Builder


 YouTube: “AWS in 10 Minutes” series by TechWorld with Nana

🧰 6. Version Control & CI/CD

 Git (clone, commit, branch, merge, pull requests)


 GitHub/GitLab
 CI/CD basics (Jenkins, GitHub Actions)
 Writing automation scripts for build/test pipelines

📚 Resources:
 Git docs: [Link]
 Jenkins tutorials: Automation Step by Step YouTube

🧠 7. Problem-Solving (DSA)

You’ll definitely face coding challenges.

Focus areas:

 Arrays, Strings, Linked Lists, Stacks, Queues


 HashMaps, Sets
 Sorting & Searching
 Recursion & Backtracking
 Trees & Graphs
 Sliding Window, Two Pointers
 Dynamic Programming (basic)

📚 Practice on:

 LeetCode (Easy → Medium):


→ Tags: Arrays, HashMap, Sliding Window
 GeeksforGeeks “SDE Sheet”

💬 8. Soft Skills

 Communicate clearly about your code and design decisions.


 Learn to explain “why” you chose a data structure or design.
 Mock interviews on Pramp or InterviewBuddy.
Java OOPS Concepts

1. Encapsulation: The protective shield


Encapsulation is the mechanism of bundling data (variables) and the
methods that operate on that data into a single unit, which is a class.
 Data hiding: A key feature of encapsulation is data hiding,
achieved by declaring variables as private. This prevents direct
access to an object's internal state from outside the class.
 Controlled access: To interact with the hidden data, you provide
public "getter" and "setter" methods. These methods add a layer
of control, allowing you to validate data before it is set and
expose only necessary information.
2. Inheritance: The "is-a" relationship
Inheritance is a mechanism that allows a new class (subclass or child
class) to inherit fields and methods from an existing class (superclass or
parent class). This promotes code reuse and creates a hierarchical
classification of objects.
 Extending functionality: The subclass can reuse the parent's code
and add its own unique fields and methods.
 super keyword: This keyword is used to refer to and call the
parent class's constructor or methods.
Abstraction
Abstraction in Java is the process of hiding internal implementation
details and showing only essential functionality to the user. It focuses
on what an object does rather than how it does it.
Key features of abstraction
 Abstraction hides the complex details and shows only essential
features.
 Abstract classes may have methods without implementation and
must be implemented by subclasses.
 By abstracting functionality, changes in the implementation do
not affect the code that depends on the abstraction.
How to Achieve Abstraction in Java?
Java provides two ways to implement abstraction, which are listed
below:
 Abstract Classes (Partial Abstraction)
 Interface (100% Abstraction)
Real-Life Example of Abstraction
The television remote control is the best example of abstraction. It
simplifies the interaction with a TV by hiding all the complex
technology. We don't need to understand how the TV works internally;
we just need to press the button to change the channel or adjust the
volume.
// Working of Abstraction in Java
abstract class Geeks {
abstract void turnOn();
abstract void turnOff();
}

// Concrete class implementing the abstract methods


class TVRemote extends Geeks {
@Override
void turnOn() {
[Link]("TV is turned ON.");
}

@Override
void turnOff() {
[Link]("TV is turned OFF.");
}
}

// Main class to demonstrate abstraction


public class Main {
public static void main(String[] args) {
Geeks remote = new TVRemote();
[Link]();
[Link]();
}
}

Output
TV is turned ON.
TV is turned OFF.
Explanation:
 Geeks is abstract class defining turnOn() and turnOff() methods.
 TVRemote class implements the abstract methods with specific logic.
 Main class uses Geeks remote = new TVRemote(); to interact without knowing the
internal implementation.

check this link


[Link]

Abstract class
An abstract class is a way to achieve abstraction in Java. It is declared
using the abstract keyword and can contain both abstract methods non
non-abstract methods. Abstract classes cannot be instantiated directly
and are meant to be extended by subclasses. Besides abstraction,
abstract classes also allow code reusability through shared behavior
and state.
Consider a classic “shape” example, perhaps used in a computer-aided
design system or game simulation. The base type is “shape” and each
shape has a color, size, and so on. From this, specific types of shapes
are derived(inherited)-circle, square, triangle, and so on — each of
which may have additional characteristics and behaviors. For example,
certain shapes can be flipped. Some behaviors may be different, such as
when you want to calculate the area of a shape. The shape hierarchy
shows both the similarities that all shapes share and the differences
that makes each one unique.
Example:
This program defines an abstract class Shape with an abstract method
area() and a concrete method getColor(), demonstrating partial
abstraction. It shows how an abstract class can have constructors and
both implemented and unimplemented methods.

abstract class Shape {


String color;

// these are abstract methods


abstract double area();
public abstract String toString();

// abstract class can have the constructor


public Shape(String color)
{
[Link]("Shape constructor called");
[Link] = color;
}

// this is a concrete method


public String getColor() { return color; }
}
class Circle extends Shape {
double radius;

public Circle(String color, double radius)


{

// calling Shape constructor


super(color);
[Link]("Circle constructor called");
[Link] = radius;
}

@Override double area()


{
return [Link] * [Link](radius, 2);
}

@Override public String toString()


{
return "Circle color is " + [Link]()
+ "and area is : " + area();
}
}
class Rectangle extends Shape {

double length;
double width;

public Rectangle(String color, double length,


double width)
{
// calling Shape constructor
super(color);
[Link]("Rectangle constructor called");
[Link] = length;
[Link] = width;
}

@Override double area() { return length * width; }

@Override public String toString()


{
return "Rectangle color is " + [Link]()
+ "and area is : " + area();
}
}
public class Test {
public static void main(String[] args)
{
Shape s1 = new Circle("Red", 2.2);
Shape s2 = new Rectangle("Yellow", 2, 4);

[Link]([Link]());
[Link]([Link]());
}
}
Another Example

This program defines an abstract class Shape with an abstract method


area() and a concrete method getColor(), demonstrating partial
abstraction. It shows how an abstract class can have constructors and
both implemented and unimplemented methods.

// Abstract Class declared


abstract class Animal {
private String name;

public Animal(String name) {


[Link] = name;
}

public abstract void makeSound();

public String getName() {


return name;
}
}

// Abstracted class
class Dog extends Animal {
public Dog(String name) {
super(name);
}

public void makeSound()


{
[Link](getName() + " barks");
}
}

// Abstracted class
class Cat extends Animal {
public Cat(String name) {
super(name);
}

public void makeSound()


{
[Link](getName() + " meows");
}
}

// Driver Class
public class Geeks {

// Main Function
public static void main(String[] args)
{
Animal myDog = new Dog("ABC");
Animal myCat = new Cat("XYZ");

[Link]();
[Link]();
}
}

Output
ABC barks
XYZ meows

Interface

An Interfaces is a blueprint of a class used to achieve 100% abstraction


in Java. It can contain abstract methods and constants, but no method
bodies (except default and static methods from Java 8 onward).
Implementation: To implement an interface, we use the keyword
“implements” with a class.
Example: Below is the Implementation of Abstraction using an
Interface.

// Define an interface named Shape


interface Shape {
double calculateArea(); // Abstract method for
// calculating the area
}

// Implement the interface


// in a class named Circle
class Circle implements Shape {
private double r; // radius

// Constructor for Circle


public Circle(double r) {
this.r = r;
}

// Implementing the abstract method


// from the Shape interface
public double calculateArea()
{
return [Link] * r * r;
}
}

// Implement the interface in a


// class named Rectangle
class Rectangle implements Shape {
private double length;
private double width;

// Constructor for Rectangle


public Rectangle(double length, double width)
{
[Link] = length;
[Link] = width;
}

// Implementing the abstract


// method from the Shape interface
public double calculateArea() {
return length * width;
}
}

// Main class to test the program


public class Main {
public static void main(String[] args)
{
// Creating instances of Circle and Rectangle
Circle c = new Circle(5.0);
Rectangle rect = new Rectangle(4.0, 6.0);

[Link]("Area of Circle: "


+ [Link]());
[Link]("Area of Rectangle: "
+ [Link]());
}
}

Output
Area of Circle: 78.53981633974483
Area of Rectangle: 24.0
Advantages of Abstraction
 Abstraction makes complex systems easier to understand by
hiding the implementation details.
 Abstraction keeps different parts of the system separated.
 Abstraction maintains code more efficiently.
 Abstraction increases security by only showing the necessary
details to the user.
Disadvantages of Abstraction
 It can add unnecessary complexity if overused.
 May reduce flexibility in implementation.
 Makes debugging and understanding the system harder for
unfamiliar [Link] from abstraction layers can affect
performance.
Encapsulation

Encapsulation is defined as the process of wrapping data and methods


into a single unit, typically a class. It is the mechanism that binds
together the code and the data. It manipulates. Another way to think
about encapsulation is that it is a protective shield that prevents the
data from being accessed by the code outside this shield.

class Employee {
// Private fields (encapsulated data)
private int id;
private String name;

// Setter methods
public void setId(int id) {
[Link] = id;
}

public void setName(String name) {


[Link] = name;
}

// Getter methods
public int getId() {
return id;
}

public String getName() {


return name;
}
}

public class Main {


public static void main(String[] args) {
Employee emp = new Employee();

// Using setters
[Link](101);
[Link]("Geek");

// Using getters
[Link]("Employee ID: " + [Link]());
[Link]("Employee Name: " + [Link]());
}
}

Output
Employee ID: 101
Employee Name: Geek

Inheritance
Inheritance is an important pillar of OOP (Object Oriented
Programming). It is the mechanism in Java by which one class is allowed
to inherit the features (fields and methods) of another class. We are
achieving inheritance by using the extends keyword. Inheritance is also
known as an "is-a" relationship.
Example: Dog, Cat, Cow can be a Derived Class of the Animal Base
Class.
Example

// Superclass (Parent)
class Animal {
void eat() {
[Link]("Animal is eating...");
}

void sleep() {
[Link]("Animal is sleeping...");
}
}

// Subclass (Child) - Inherits from Animal


class Dog extends Animal {
void bark() {
[Link]("Dog is barking!");
}
}

public class Main {


public static void main(String[] args) {
Dog myDog = new Dog();

// Inherited methods (from Animal)


[Link]();
[Link]();
// Child class method
[Link]();
}
}

Output
Animal is eating...
Animal is sleeping...
Dog is barking!

Polymorphism
The word polymorphism means having many forms, and it comes from
the Greek words poly (many) and morph (forms). This means one entity
can take many forms. In Java, polymorphism allows the same method
or object to behave differently based on the context, especially on the
project's actual runtime class.

Types of Polymorphism
Polymorphism in Java is mainly of 2 types as mentioned below:
1. Method Overloading
2. Method Overriding
Method Overloading and Method Overriding
1. Method Overloading: Also known as compile-time polymorphism, is
the concept of Polymorphism where more than one method shares the
same name with a different signature(Parameters) in a class. The return
type of these methods can or cannot be the same.
2. Method Overriding: Also known as run-time polymorphism, is the
concept of Polymorphism where a method in the child class has the
same name, return type, and parameters as in the parent class. The
child class provides the implementation in the method already written.
Examples

// Parent Class
class Parent {
// Overloaded method (compile-time polymorphism)
public void func() {
[Link]("[Link]()");
}

// Overloaded method (same name, different parameter)


public void func(int a) {
[Link]("[Link](int): " + a);
}
}

// Child Class
class Child extends Parent {
// Overrides [Link](int) (runtime polymorphism)
@Override
public void func(int a) {
[Link]("[Link](int): " + a);
}
}

public class Main {


public static void main(String[] args) {
Parent parent = new Parent();
Child child = new Child();
// Dynamic dispatch
Parent polymorphicObj = new Child();

// Method Overloading (compile-time)


[Link]();
[Link](10);

// Method Overriding (runtime)


[Link](20);

// Polymorphism in action
[Link](30);
}
}

Output
[Link]()
[Link](int): 10
[Link](int): 20
[Link](int): 30

Advantages of OOPs over Procedure-Oriented Programming Language


Object-oriented programming (OOP) offers several key advantages over
procedural programming:
 By using objects and classes, you can create reusable
components, leading to less duplication and more efficient
development.
 It provides a clear and logical structure, making the code easier to
understand, maintain, and debug.
 OOP supports the DRY (Don't Repeat Yourself) principle. This
principle encourages minimizing code repetition, leading to
cleaner, more maintainable code. Common functionalities are
placed in a single location and reused, reducing redundancy.
 By reusing existing code and creating modular components, OOP
allows for quicker and more efficient application development.
Disadvantages of OOPs
 OOP has concepts like classes, objects, inheritance, etc. For
beginners, this can be confusing and takes time to learn.
 If we write a small program, using OOP can feel too heavy. We
might have to write more code than needed just to follow the
OOP structure.
 The code is divided into different classes and layers, so finding and
fixing bugs can sometimes take more time.
 OOP creates a lot of objects, so it can use more memory
compared to simple programs written in a procedural way.

You might also like