Java OOP Notes – Expanded 7-Marks Answers
These answers are written in simple wording and expanded to a 7-marks depth. Each
question includes definitions, key points, examples, and short summaries where helpful.
Section 1: Classes & Objects
1) Difference between a Class and an Object
A class is a blueprint that declares what data (fields) and behavior (methods) objects will
have. It does not store real data; it only describes the structure. An object is a real,
memory-occupying instance created from the class.
• Analogy: Class = House map; Object = Actual built house.
• Class exists once; objects many.
• Objects hold per-instance data.
• Memory differences.
• Lifecycle differences.
2) Define classes with fields and methods
(class Student example...)
3) Create and use objects in Java
(Student s1 example...)
4) Simple Java program using classes and objects
(Car class example...)
5) Define an object, creation process, and class member usage.
6) Differentiate between Class and Object
• Nature
• Memory
• Count
• Behavior/state
• Lifetime
7) Advantages of using classes and objects
• Better organization
• Reusability
• Real-life modeling
• Encapsulation
• Debugging ease
• Extensibility
• OOP features
Section 2: Constructors
1) Define constructor and its role
• Types etc.
2) Constructor vs Method
3) Characteristics
4) Default constructor
5) Parameterized constructor
6) Constructor execution
7) Constructor overloading
8) Program example
9) Real-life applications
Section 3: Destructor & Garbage Collection
(Details...)
Section 4: Encapsulation
(Details...)
Section 5: Access Modifiers
(Details...)
Section 6: Constants & final keyword
(Details...)
Functions and Operator Overloading Methods
1) What is function overloading in Java? (7-marks)
Function overloading in Java allows multiple methods with the same name but different
parameter lists. It increases flexibility by handling different input types with the same
method name, improves readability and organization, supports compile-time
polymorphism, and avoids creating unnecessary method names.
2) Conditions required for method overloading (7-marks)
Methods must share the same name.
Parameter count must differ OR types must differ OR order must differ.
Return type alone cannot overload a method.
Access modifiers may differ but do not affect overloading.
Overloaded methods may throw different exceptions.
Compiler selects correct version based on argument matching at compile-time.
Overloading groups similar behaviors cleanly under one method name.
3) Why is function overloading called compile-time polymorphism? (7-marks)
Because the compiler selects the correct overloaded method before the program runs. The
decision is based on the arguments provided. This matching occurs during compilation,
ensuring speed, safety, and early detection of errors, unlike runtime polymorphism.
4) Does Java support operator overloading? Explain. (7-marks)
Java does not support full operator overloading like C++. Only the + operator is overloaded
for string concatenation. All other operators cannot be redefined for custom classes. This
keeps Java simple, predictable, and easy to maintain.
5) Why does Java restrict operator overloading? (7-marks)
To keep the language simple and beginner-friendly.
To avoid confusion caused by redefining operator behavior.
To prevent misuse where operators behave unexpectedly.
To maintain readability and uniformity across Java applications.
To reduce compiler complexity and eliminate ambiguous expressions.
To avoid errors common in languages with operator overloading.
To encourage method-based clarity rather than operator trickiness.