0% found this document useful (0 votes)
27 views4 pages

Java Oops Review

The document provides a comprehensive overview of Object-Oriented Programming (OOP) in Java, detailing its four main pillars: encapsulation, inheritance, polymorphism, and abstraction. It includes definitions, examples, and benefits of each concept, as well as key differences and common interview questions related to OOP. Additionally, real-world examples illustrate the application of these concepts in practical scenarios.

Uploaded by

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

Java Oops Review

The document provides a comprehensive overview of Object-Oriented Programming (OOP) in Java, detailing its four main pillars: encapsulation, inheritance, polymorphism, and abstraction. It includes definitions, examples, and benefits of each concept, as well as key differences and common interview questions related to OOP. Additionally, real-world examples illustrate the application of these concepts in practical scenarios.

Uploaded by

yashagr12345678
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

Java OOPs - Full Review Notes for Viva & Interview

🔥 OOPs in Java – Full Review

🔏 What is OOP?

OOP (Object-Oriented Programming) is a style of programming where real-world entities are modeled
as objects using classes.

Java is an Object-Oriented Language where everything revolves around class and object.

🌟 4 Pillars of OOPs in Java

1. Encapsulation – Data Hiding

• Wrapping data and methods together inside a class.


• Variables are made private; access via getters/setters.

class Student {
private int age;
public void setAge(int a) { age = a; }
public int getAge() { return age; }
}

Benefit: Security, controlled access, data protection.

2. Inheritance – Reusability

• One class (child) inherits properties of another (parent) using extends .

class Animal {
void sound() { System.out.println("Animal sound"); }
}
class Dog extends Animal {
void bark() { System.out.println("Dog barks"); }
}

Benefit: Code reuse, hierarchy, simplicity.

3. Polymorphism – Many Forms

Compile-time (Method Overloading):

1
class Math {
int add(int a, int b) { return a + b; }
int add(int a, int b, int c) { return a + b + c; }
}

Run-time (Method Overriding):

class Animal {
void sound() { System.out.println("Animal sound"); }
}
class Cat extends Animal {
void sound() { System.out.println("Meow"); }
}

Benefit: Flexibility, dynamic behavior.

4. Abstraction – Hiding Complex Details

• Shows essential features, hides implementation.


• Done via:
• Abstract classes
• Interfaces

Abstract class example:

abstract class Shape {


abstract void draw();
}
class Circle extends Shape {
void draw() { System.out.println("Drawing Circle"); }
}

Interface example:

interface Vehicle {
void start();
}
class Car implements Vehicle {
public void start() { System.out.println("Car starts"); }
}

Benefit: Focus on "what" not "how", security, modularity.

2
📌 Other Key Concepts

Concept Description

Class Blueprint of an object

Object Instance of a class

Constructor Special method to initialize objects

this keyword Refers to current object

super keyword Refers to parent class

final keyword Prevents modification

static keyword Belongs to class, not object

🧠 Differences You Should Know

Concept Description

Abstraction vs
Abstraction hides logic, Encapsulation hides data
Encapsulation

Overloading = same name, diff args. Overriding = same method in


Overloading vs Overriding
child

Class vs Object Class = design, Object = instance

🧮 Common Viva Questions


1. What is OOP?
2. What are the 4 pillars of OOP?
3. What is inheritance? Give real-life example.
4. Difference between abstract class and interface?
5. What is method overloading and overriding?
6. What is encapsulation in Java?
7. Can we create object of abstract class? (No)
8. Can interface have constructor? (No)
9. Can interface have variables? (Yes, but public static final by default)
10. Difference between this and super ?

🔗 Real-World Examples

Concept Example

Encapsulation ATM hides internal details

3
Concept Example

Inheritance Son inherits father’s traits

Polymorphism Person behaves as student/friend/employee

Abstraction Driving car without knowing engine working

Best of luck for your review Yash! You got this! 🙌

You might also like