
Asked in SAP
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 attributegrandFatherName
.Father
: This class inherits fromGrandFather
. It should have a parameterized constructor with an additional argument forfatherName
.Son
: This class inherits fromFather
. It should have a parameterized constructor with an additional argumentsonName
, and it must include a methodprintName
to displaysonName
,fatherName
, andgrandFatherName
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!
Add answer anonymously...
Top Software Developer Interview Questions Asked at SAP
Q. If you have 1 million requests, how will you manage that?
Q. Implement a stack using queues.
Q. Write a function that reverses a string.
Interview Questions Asked to Software Developer at Other Companies
Top Skill-Based Questions for SAP Software Developer
Algorithms Interview Questions and Answers
250 Questions
Data Structures Interview Questions and Answers
250 Questions
Web Development Interview Questions and Answers
250 Questions
Java Interview Questions and Answers
250 Questions
SQL Interview Questions and Answers
250 Questions
Software Development Interview Questions and Answers
250 Questions
Stay ahead in your career. Get AmbitionBox app


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
AmbitionBox Awards
Get AmbitionBox app

