1. Which list names the four commonly cited pillars of OOP?
- Encapsulation, abstraction, inheritance, polymorphism
- Variables, loops, functions, arrays
- Compilation, linking, loading, execution
- Classes, files, packages, modules
जवाब देखें
जवाब: Encapsulation, abstraction, inheritance, polymorphism
These four principles are the classic foundation of object-oriented design.
पाठ: Why Object-Oriented Programming
2. After `Student b = a;` in Java, what does b refer to?
- A new copy of the object
- Nothing until it is initialised
- The Student class itself
- The same object that a refers to
जवाब देखें
जवाब: The same object that a refers to
Assignment copies the reference, so both variables point to one object.
पाठ: Classes, Objects, State and Identity
3. What happens to Java's default no-argument constructor once you write any constructor for a class?
- It is still generated automatically
- It becomes static
- It is no longer provided; you must write it yourself if you need it
- It becomes private
जवाब देखें
जवाब: It is no longer provided; you must write it yourself if you need it
Java only supplies the default constructor when the class declares no constructors.
पाठ: Constructors, this and Static Members