menu

Inheritance in Java


1. What is the purpose of the 'super' keyword in Java?

To call a method or constructor of a superclass

To declare a superclass

To access a private field of a superclass

To override a method of a superclass


2. Which type of inheritance is used in Java for classes?

Single inheritance

Multiple inheritance

Hybrid inheritance

Hierarchical inheritance


3. Which keyword is used to implement method overloading in Java?

override

final

abstract

none of the above


4. Which keyword is used to prevent a class from being inherited by other classes?

abstract

final

static

synchronized


5. Which keyword is used to invoke the constructor of the parent class?

this

super

extends

implements


6. Which keyword is used to create an abstract class in Java?

abstract

final

static

synchronized


7. Which of the following is not a superclass of the String class in Java?

Object

CharSequence

Number

Comparable


8. Which type of inheritance is used in Java for interfaces?

Single inheritance

Multiple inheritance

Hybrid inheritance

Hierarchical inheritance


9. Which access modifier allows a subclass to access the protected members of its parent class?

private

public

protected

default


10. Which of the following is not a benefit of inheritance in Java?

Code reusability

Polymorphism

Encapsulation

Modularity