menu

Inheritance in Java


1. Which of the following statements is true regarding inheritance in Java?

A class can inherit from multiple classes in Java.

A subclass can access private members of its superclass.

Constructors are not inherited in Java.

Inheritance is not supported in Java.


2. Which method of the Object class is used to return a hash code value for an object?

hashCode()

equals()

toString()

getClass()


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


4. Which keyword is used to create an interface in Java?

abstract

interface

implements

extends


5. Which keyword is used to prevent a class from being inherited in Java?

final

static

abstract

private


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

Single inheritance

Multiple inheritance

Hybrid inheritance

Hierarchical inheritance


7. Which of the following is not a type of inheritance in Java?

Single inheritance

Multiple inheritance

Multilevel inheritance

Hybrid inheritance


8. Which of the following statements is true regarding the 'this' keyword in Java?

It can be used to access a static field of a class.

It can be used to call a method of a superclass.

It can be used to refer to the current instance of a class.

It can be used to declare a constructor.


9. Which of the following is NOT a type of inheritance in Java?

Single inheritance

Multiple inheritance

Hybrid inheritance

Hierarchical inheritance


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

override

final

abstract

none of the above