Concepts Questions and Answers
Already Passed
When an interface method is implemented in a class, what access modifier must it have?
A) private
B) protected
✔✔C) public
D) final
Which of the following is NOT a feature of polymorphism in Java?
A) Method overloading
B) Method overriding
✔✔C) Multiple class inheritance
D) Dynamic method dispatch
What happens if a subclass constructor does not explicitly call a superclass constructor?
✔✔A) The default constructor of the superclass is automatically called
B) A compilation error occurs
1
,C) The subclass cannot be instantiated
D) The program crashes at runtime
Can a subclass access private fields of a superclass?
A) Yes, directly
✔✔B) No, only through getter methods or protected fields
C) Yes, but only if the subclass is in the same package
D) Yes, by using the super keyword
What happens if a method in a subclass has the same name as a method in its superclass but a
different return type?
✔✔A) A compilation error occurs unless it is a covariant return type
B) The subclass method overrides the superclass method
C) The superclass method is hidden but still accessible
D) Java automatically converts the return type
Which of the following correctly describes the protected access modifier?
✔✔A) It allows access within the same package and subclasses
2
, B) It allows access only within the same class
C) It allows access only within the same package
D) It allows access from any class in any package
Can an abstract class implement an interface?
✔✔A) Yes, but it does not have to implement all methods
B) No, only concrete classes can implement interfaces
C) Yes, but it must implement all methods
D) No, abstract classes cannot extend anything
If a superclass method is final, what happens if a subclass tries to override it?
✔✔A) A compilation error occurs
B) The method is overridden successfully
C) The method becomes abstract
D) The subclass method executes instead
What does the super keyword do in Java?
A) It refers to the current instance of a class
3