11.) What is a subclass in Java?
A) A class that is lower in the class hierarchy
B) A class that inherits from another class (superclass)
C) A class that overrides methods in the superclass
D) A class that is created before a superclass
12.) Which type of polymorphism is resolved at runtime and is based on the actual object’s type?
A) Compile-time polymorphism
B) Run-time polymorphism
C) Method polymorphism
D) Static polymorphism
13.) QuesWhat is method overloading in Java?tion
A) Creating multiple methods with the same name but different parameters
B) Hiding methods from the superclass
C) Calling a method from within another method
D) Creating methods inside the main method
14.) Can a subclass access private members (fields and methods) of its superclass in Java?
A) Yes, always
B) Yes, only if they are declared as static
C) No, never
D) Yes, only if they are declared as public
15.) What is the “instanceof” operator used for in Java?
A) To create a new instance of a class
B) To compare two objects for equality
C) To check if an object is null
D) To test if an object is of a particular class type
16.) Which method is called first when an object of a subclass is created in Java?
A) The constructor of the subclass
B) The constructor of the superclass
C) The main method
D) The finalize method
17.) What is the purpose of method hiding in Java inheritance?
A) To prevent a subclass from inheriting methods
B) To override superclass methods with new implementations
C) To expose private methods of the superclass
D) To define methods with the same name in both the superclass and subclass
18.) In Java, can a class inherit from multiple classes (achieve multiple inheritance)?
A) Yes, always
B) Yes, but only if the classes are in the same package
C) No, never
D) Yes, but only if the classes have the same attributes
19.) What is a constructor chaining in Java?
A) Calling the superclass constructor from a subclass constructor
B) Creating multiple constructors with the same parameters
C) Hiding the constructor of the superclass
D) Calling a method from within a constructor
20.) What is method overloading based on in Java?
A) The return type of methods
B) The method names
C) The parameter types and/or the number of parameters
D) The access modifiers of methods