menu

Inheritance in Java

Inheritance in Java - Important Points


1.

Which keyword is used in Java to implement inheritance?

A. super

B. this

C. extends

D. implements

Discuss Work Space

Answer: option c

Explanation:

The 'extends' keyword is used in Java to implement inheritance.


2. Which type of inheritance allows a class to inherit properties and behavior from multiple parent classes?

A. Single inheritance

B. Multiple inheritance

C. Multilevel inheritance

D. Hybrid inheritance

Discuss Work Space

Answer: option b

Explanation:

Multiple inheritance allows a class to inherit properties and behavior from multiple parent classes.

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

A. private

B. public

C. protected

D. default

Discuss Work Space

Answer: option c

Explanation:

The 'protected' access modifier allows a subclass to access the protected members of its parent class.

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

A. abstract

B. final

C. static

D. synchronized

Discuss Work Space

Answer: option b

Explanation:

The 'final' keyword is used to prevent a class from being inherited by other classes.

5. What is the first method that is executed when an object of a class is created?

A. finalize()

B. constructor

C. main()

D. start()

Discuss Work Space

Answer: option b

Explanation:

The constructor is the first method that is executed when an object of a class is created.


Subscribe for Latest Career Trends
Subscribe Now
Use AI and ChatGPT for Career Guidance

Unlock Your Future

Join Now
Worried for Placements in 2024?

Join FAST TRACK Course

Join Now
Supercharge Your SUCCESS

Join All in One Placement Mock Tests-2024

Join Now