Skip to content

Latest commit

 

History

History
39 lines (27 loc) · 1.63 KB

Answer-CoreJava MCQ.md

File metadata and controls

39 lines (27 loc) · 1.63 KB

#14

Answer list for the provided Java MCQs Issue 14:

  1. 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

  2. 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

  3. What concept is demonstrated by the following code snippet?
    Answer: C) Polymorphism

  4. Which of the following is NOT a feature of Abstraction?
    Answer: D) Reusing code between classes

  5. What will be the output of the following code, demonstrating Constructor Chaining?
    Answer: C) Parent Constructor
    Child Constructor

  6. What will be the output of the following Java program?
    Answer: B) Derived display

  7. What will be the output of the following Java code?
    Answer: B) 15 5

  8. What will be the output of the following Java program?
    Answer: C) Class A Constructor
    Class B Constructor

  9. 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

  10. What will be the output of the following program that demonstrates inner classes and their interaction with variables?
    Answer: A) 30
    20
    10