41.) In Java, what is the role of an abstract class in relation to polymorphism?
A) An abstract class restricts polymorphism to its subclasses only.
B) An abstract class eliminates the need for polymorphism.
C) An abstract class cannot be used in polymorphism.
D) An abstract class provides a base for achieving polymorphism.
42.) Consider an abstract class A with a final method “display().” Can a subclass B override this method?
A) Yes, by using the “override” keyword.
B) Yes, by using the “final” keyword.
C) No, the final method cannot be overridden.
D) Yes, only if subclass B is also abstract.
43.) In Java, can a class be both an abstract class and an interface at the same time?
A) No, a class cannot be both an abstract class and an interface.
B) Yes, but only if the class has no methods.
C) Yes, but only if the interface is also abstract.
D) Yes, a class can be both an abstract class and an interface.
44.) What is the purpose of the “default” method in an interface in Java 8 and later versions?
A) To mark a method as the default method of the interface
B) To provide a default implementation for the method
C) To override methods in subclasses
D) To prevent the method from being overridden
45.) What is the significance of the “super()” statement in the constructor of an abstract class in Java?
A) It creates an instance of the superclass.
B) It calls the constructor of the immediate subclass.
C) It invokes the constructor of the superclass.
D) It prevents instantiation of the abstract class.
46.) Which modifier can be applied to a method in an interface to prevent it from being inherited by implementing classes?
A) public
B) private
C) final
D) static
47.) In Java, can an interface extend a class?
A) Yes, but only if the interface is marked as “hybrid.”
B) Yes, but only if the class is marked as “interface.”
C) Yes, an interface can extend another interface, not a class.
D) No, an interface cannot extend a class.
48.) Which type of inheritance involves inheriting from more than one class in Java?
A) Single inheritance
B) Multilevel inheritance
C) Multiple inheritance
D) Hierarchical inheritance
49.) In Java, what is a covariant return type?
A) A return type that is always void.
B) A return type that is more specific than the overridden method’s return type.
C) A return type that is less specific than the overridden method’s return type.
D) A return type that is always an interface.
50.) Can a class be marked as both “final” and “abstract” in Java?
A) Yes, but only if it has no methods.
B) Yes, a class can be marked as both “final” and “abstract.”
C) No, a class cannot be both “final” and “abstract.”
D) Yes, but only if it is marked as “protected.”