Answers Already Passed
Can a class be both a superclass and a subclass at the same time?
✔✔ Yes, a class can extend another class while being extended itself.
What is polymorphism?
✔✔ Polymorphism allows a subclass to be treated as an instance of its superclass, enabling
dynamic method invocation.
How does Java achieve runtime polymorphism?
✔✔ Through method overriding and dynamic method dispatch.
What is method overloading?
✔✔ Defining multiple methods in the same class with the same name but different parameters.
Can constructors be inherited?
✔✔ No, constructors are not inherited, but a subclass can call a superclass constructor using
`super()`.
1
, What is inheritance in Java?
✔✔ Inheritance is a mechanism that allows a class to acquire the properties and methods of
another class.
How do you declare a subclass in Java?
✔✔ By using the `extends` keyword followed by the name of the superclass.
Can a subclass override a superclass method?
✔✔ Yes, a subclass can provide its own implementation of a method using the same signature.
What is method overriding?
✔✔ It is the process of redefining a method in a subclass that already exists in the superclass.
What annotation is used to indicate that a method is overriding another method?
✔✔ The `@Override` annotation.
Can a subclass inherit private members from a superclass?
2