Answer list for the provided Java MCQs Issue 14:
-
Which of the following best demonstrates the concept of Encapsulation in Java?
Answer: B) Hiding the data members of a class by declaring them private and providing public getter and setter methods -
You have a superclass Animal and a subclass Dog. Which of the following statements about Inheritance is true?
Answer: B) Dog inherits the public and protected members of Animal -
What concept is demonstrated by the following code snippet?
Answer: C) Polymorphism -
Which of the following is NOT a feature of Abstraction?
Answer: D) Reusing code between classes -
What will be the output of the following code, demonstrating Constructor Chaining?
Answer: C) Parent Constructor
Child Constructor -
What will be the output of the following Java program?
Answer: B) Derived display -
What will be the output of the following Java code?
Answer: B) 15 5 -
What will be the output of the following Java program?
Answer: C) Class A Constructor
Class B Constructor -
What will be the output of the following Java program that uses a combination of final, static, and method overriding?
Answer: C) Static method in Class A
Non-static method in Class B -
What will be the output of the following program that demonstrates inner classes and their interaction with variables?
Answer: A) 30
20
10