Multilevel Inheritance Implementation

Create a series of classes to demonstrate multilevel inheritance.

Explanation:

Create three classes to illustrate multilevel inheritance.

  • GrandFather: This class should have a parameterized constructor and an attribute grandFatherName.
  • Father: This class inherits from GrandFather. It should have a parameterized constructor with an additional argument for fatherName.
  • Son: This class inherits from Father. It should have a parameterized constructor with an additional argument sonName, and it must include a method printName to display sonName, fatherName, and grandFatherName in a specific format.

Input:

# No specific input format since this is about class and method creation

Output:

Saurabh Ramesh Suresh

Example:

Create an object of the Son class and pass: sonName as 'Saurabh', fatherName as 'Ramesh', and grandFatherName as 'Suresh'. Then call the printName method.

Constraints:

  • The constructor must initialize the attributes correctly in each class.
  • The method printName should output the names in the specified format.

Note:

The objective is to showcase inheritance and class design rather than standard input-output operations.

AnswerBot
4mo

Demonstrate multilevel inheritance with classes GrandFather, Father, and Son with specific attributes and methods.

  • Create a class GrandFather with a parameterized constructor and attribute grandFatherN...read more

Help your peers!
Select
Add answer anonymously...

SAP Software Developer interview questions & answers

A Software Developer was asked 9mo agoQ. Implement a stack using queues.
A Software Developer was asked 9mo agoQ. Write a function that reverses a string.
A Software Developer was asked 10mo agoQ. Implement a stack using other data structures.

Popular interview questions of Software Developer

A Software Developer was asked 5mo agoQ1. If you have 1 million requests, how will you manage that?
A Software Developer was asked 9mo agoQ2. Implement a stack using queues.
A Software Developer was asked 9mo agoQ3. Write a function that reverses a string.

Top HR questions asked in SAP Software Developer

A Software Developer was asked 8mo agoQ1. Introduce yourself.
A Software Developer was asked 10mo agoQ2. What is your top priority when choosing a new job?
A Software Developer was asked 10mo agoQ3. Tell me about your current project and the technologies you are using.
SAP Software Developer Interview Questions
Stay ahead in your career. Get AmbitionBox app
play-icon
play-icon
qr-code
Trusted by over 1.5 Crore job seekers to find their right fit company
80 L+

Reviews

10L+

Interviews

4 Cr+

Salaries

1.5 Cr+

Users

Contribute to help millions

Made with ❤️ in India. Trademarks belong to their respective owners. All rights reserved © 2025 Info Edge (India) Ltd.

Follow Us
  • Youtube
  • Instagram
  • LinkedIn
  • Facebook
  • Twitter
Profile Image
Hello, Guest
AmbitionBox Employee Choice Awards 2025
Winners announced!
awards-icon
Contribute to help millions!
Write a review
Write a review
Share interview
Share interview
Contribute salary
Contribute salary
Add office photos
Add office photos
Add office benefits
Add office benefits