Oriented Thinking Questions and
Answers Graded A+
What is the purpose of an abstract class in Java?
✔✔ An abstract class provides a blueprint for subclasses, allowing common behaviors to be
shared while enforcing specific method implementations.
Why can't an abstract class be instantiated?
✔✔ Abstract classes are incomplete and meant to be extended by subclasses, so they cannot be
directly instantiated.
What is an interface in Java?
✔✔ An interface is a contract that defines methods a class must implement without providing
their implementation.
How does an interface differ from an abstract class?
✔✔ An abstract class can have implemented methods, while an interface only defines method
signatures that must be implemented by a class.
1
,Why is multiple inheritance not allowed in Java?
✔✔ Multiple inheritance can create ambiguity and conflicts in method resolution, so Java avoids
it by using interfaces.
What is the purpose of the super keyword in Java?
✔✔ The super keyword is used to call a superclass constructor or access a superclass method
from a subclass.
How can constructors be overloaded in Java?
✔✔ Constructors can be overloaded by defining multiple constructors with different parameter
lists in the same class.
What happens if a class does not define a constructor?
✔✔ If no constructor is defined, Java provides a default constructor that initializes the object
with default values.
What is object-oriented thinking in Java?
✔✔ It is an approach to programming that focuses on using objects and classes to design and
build applications.
2
,What is encapsulation in Java?
✔✔ Encapsulation is the practice of restricting direct access to an object's data and providing
controlled access through methods.
How does inheritance promote code reusability?
✔✔ Inheritance allows a subclass to acquire properties and behaviors from a superclass,
reducing code duplication.
What is polymorphism in Java?
✔✔ Polymorphism is the ability of an object to take many forms, allowing a method to be
implemented in multiple ways.
Why is method overriding important in object-oriented programming?
✔✔ Method overriding allows a subclass to provide a specific implementation of a method
already defined in its superclass.
What is the difference between method overloading and method overriding?
3
, ✔✔ Method overloading occurs when multiple methods have the same name but different
parameters, while method overriding allows a subclass to modify a method from its superclass.
How does abstraction simplify program design?
✔✔ Abstraction hides complex implementation details and exposes only the necessary
functionality to the user.
Why are getters and setters used in Java?
✔✔ Getters and setters provide controlled access to private fields, ensuring encapsulation and
data integrity.
What is the difference between a static method and an instance method?
✔✔ A static method belongs to the class and can be called without an object, while an instance
method belongs to an object and requires an instance to be called.
What is the purpose of the this keyword in Java?
✔✔ The this keyword refers to the current instance of the class and is used to differentiate
instance variables from local variables.
4