Answers Graded A+
Can a subclass inherit from a final class?
✔✔ No, a final class cannot be extended.
What does the `final` keyword do when applied to a method?
✔✔ A final method cannot be overridden by subclasses.
Can a subclass inherit constructors from a superclass?
✔✔ No, constructors are not inherited, but a subclass can call them using `super()`.
What is the `instanceof` operator used for in inheritance?
✔✔ The `instanceof` operator is used to check if an object is an instance of a specific class or
subclass.
Can a subclass have additional methods and properties not present in the superclass?
✔✔ Yes, a subclass can define additional methods and properties.
1
,What is the advantage of using inheritance in Java?
✔✔ Inheritance promotes code reusability and better organization by allowing shared behavior
across multiple classes.
What happens if a subclass does not provide an implementation for an abstract method from its
superclass?
✔✔ The subclass must be declared abstract or provide an implementation for the abstract
method.
What is multiple inheritance, and does Java support it?
✔✔ Multiple inheritance is when a class inherits from more than one superclass. Java does not
support it with classes but allows it through interfaces.
Can a subclass change the return type of an overridden method?
✔✔ Yes, a subclass can return a subtype (covariant return type) of the original method’s return
type.
What happens if a subclass does not override a method from its superclass?
✔✔ The subclass inherits the method and uses it as defined in the superclass.
2
, Can a superclass method be called from a subclass if it has been overridden?
✔✔ Yes, the superclass method can be called using `super.methodName()`.
What is hierarchical inheritance?
✔✔ Hierarchical inheritance occurs when multiple subclasses inherit from the same superclass.
Can a subclass call a private method of the superclass?
✔✔ No, private methods of a superclass are not accessible in the subclass
What is inheritance in Java?
✔✔ Inheritance is a mechanism where a new class derives properties and behaviors from an
existing class.
What keyword is used to create a subclass in Java?
✔✔ The `extends` keyword is used to create a subclass.
Can a subclass inherit private members of a superclass?
3