
Concept Notes: Java OOPs Concepts
🔹 1. What is OOP?
Object-Oriented Programming (OOP) is a method of structuring code around objects instead of functions.
🔹 2. 4 Pillars of OOP in Java
Concept | Meaning |
---|---|
Encapsulation | Wrapping data & methods into a single unit (class) |
Inheritance | One class inherits properties of another (extends ) |
Polymorphism | One task done in multiple ways (method overloading/overriding) |
Abstraction | Hiding internal details, showing only essentials (via abstract class) |
🔹 3. Key Java OOP Terms
- Class: Blueprint for an object
- Object: Instance of a class
- Constructor: Special method to initialize objects
- Method Overloading: Same method name, different parameters
- Method Overriding: Same method in child class changes parent class method
🔹 4. Sample Code
class Animal {
void sound() {
System.out.println("Animal sound");
}
}
class Dog extends Animal {
void sound() {
System.out.println("Bark");
}
}
Java OOPs MCQs – Day 4 Night
1️⃣ What is encapsulation in Java?
A) Hiding data
B) Inheriting class
C) Overloading methods
D) Multiple inheritance
2️⃣ Which keyword is used for inheritance in Java?
A) inherit
B) derive
C) extend
D) implements
3️⃣ What is the output of method overriding?
A) Parent method runs
B) Child method replaces parent
C) Compile-time error
D) Method is skipped
4️⃣ Which is not part of OOPs in Java?
A) Inheritance
B) Polymorphism
C) Encapsulation
D) Compilation
5️⃣ What is a class in Java?
A) Runtime instance
B) Collection of statements
C) Blueprint for objects
D) A memory location
6️⃣ What is constructor used for?
A) Destroying object
B) Initializing object
C) Accessing methods
D) Overriding class
7️⃣ What is method overloading?
A) Same method name, same parameters
B) Same method name, different parameters
C) Same method body
D) No return type
8️⃣ What does super keyword do?
A) Creates class
B) Refers to parent class
C) Creates object
D) Calls main()
9️⃣ Which concept allows same method to behave differently?
A) Inheritance
B) Polymorphism
C) Encapsulation
D) Data hiding
🔟 Which OOP principle shows only essential info?
A) Abstraction
B) Inheritance
C) Encapsulation
D) Polymorphism
✅ Answer Key
Q.No | Answer |
---|---|
1 | A |
2 | C |
3 | B |
4 | D |
5 | C |
6 | B |
7 | B |
8 | B |
9 | B |
10 | A |
🧠 Explanations
- Q1: Encapsulation wraps data and code together.
- Q2:
extends
is the Java keyword for inheritance. - Q3: Overriding allows child method to replace parent’s.
- Q4: Compilation is a general concept, not OOP-specific.
- Q5: Class is a blueprint/template for objects.
- Q6: Constructor initializes new objects.
- Q7: Overloading = same name, different params.
- Q8:
super
accesses parent class methods. - Q9: Polymorphism means many forms (overload/override).
- Q10: Abstraction hides unnecessary implementation details.
📥 PDF Available
Join Telegram group and get all notes, MCQs, and explanations as downloadable PDFs 👇
👉 @learnnewthingsoffcial
💬 Comment Task
🗣 Which OOPs concept do you find toughest – Overloading, Inheritance, or Abstraction?
Let us know, and we’ll post a mini YouTube Short tomorrow 🔥