Multilevel Inheritance
Create a class GrandFather that has a parameterized constructor and a grandFatherName attribute.
Create another class Father that inherits the property of GrandFather and has a parameterized constructor with an additional argument fatherName.
Create another class Son that inherits Father's property and has a parameterized constructor with an additional argument sonName and a printName method that prints the sonName,fatherName, and grandFatherName into the format as shown below in SampleOutput 1.
You need to create the object of Son class and pass the value of sonName,fatherName,grandFatherName as 'Saurabh', 'Ramesh', and 'Suresh' respectively and call the printName method.
CodingNinjas
author
2y
Intuitive Approach
- First, we are creating class Grandfather has an attribute grandfathername after that creating class
- Father has an additional attribute fathername now further creating a class has all ...read more
Help your peers!
Add answer anonymously...
Top SAP Software Developer interview questions & answers
Popular interview questions of Software Developer
Stay ahead in your career. Get AmbitionBox app
Helping over 1 Crore job seekers every month in choosing their right fit company
65 L+
Reviews
4 L+
Interviews
4 Cr+
Salaries
1 Cr+
Users/Month
Contribute to help millions
Get AmbitionBox app