Multilevel Inheritance in Java

Multilevel Inheritance is said to have taken place when a child class inherits from a parent class and then child class becomes the parent class for another class. This process can do on and on. For example, if class B inherits class A, then class C inherits from class B and similarly class D inherits from class C. Then class D may or may not use the members of all the previous classes.

A Sample Program showing Multilevel Inheritance


class Baby
{  
	void eat()
	{
		System.out.println("eating...");
	}  
}  
	class Sleep extends Baby
	{  
		void dream()
		{
			System.out.println("dreaming...");
		}  
	}  
	class Walk extends Sleep
	{  
		void talk()
		{
			System.out.println("talking...");
		}  
	}  
	
	class Check
{  
	public static void main(String args[])
	{  
	Walk d=new Walk();  
	d.talk();  
	d.dream();  
	d.eat();  
	}
} 
   

Program Output

Download Source code of Baby program share on :        :  

Love to hear your Views / Guidance / Recommendations on this Post…

Explore the Technology World

The mind behind Linux & GIT : Linus TorvaldsLinus Torvalds transformed technology twice — first with the Linux kernel, which helps power the Internet, and again with Git, the source code management syst ...Read MoreTensorflow and deep learningWith Tensorflow ,deep machine learning transitions from an area of research into mainstream software engineering. ...Read MoreJava program to return all possible permutations from collection of distinct numbersexample of Java program to return all possible permutations from collection of distinct numbers ...Read MoreReal Time Analytics with Spring Application Development FrameworkSpring is the most popular application development framework for enterprise Java.Millions of developers use Spring to build simple, truly portable, fast and fle ...Read MorePath Setting in Java When an application is launched from command prompt Windows OS searches for the executable program in the current working directory. The prompt throws an error ...Read MorePicture-in-Picture App for Android devices with Source CodePicture-in-Picture is a special type of multi-window mode mostly used for video playback for Android devices.Released under Apache License 2.0 , which means you ...Read MoreFacebook |Google+ | Twitter | LinkedIn | Youtube About | Cookies-Policy | Disclaimer | Site Map | Contact

Call / Visit for New Batch

Services

Why Join Us

  • ➯ Free Demo Classes
  • ➯ No Registration Fee
  • ➯ Interview Questions
  • ➯ Study Materials
  • ➯ Softwares
  • ➯ Aptitude & Reasoning
  • ➯ Placement Assitance

Address

  • MyJava Training Institute ,
  • Plot No.243 , shop No 14 ,
  • Secnd Floor , Zone-II ,
  • M.P.Nagar , Bhopal,
  • Madhya Pradesh ( 462011 )
  • ☎  08871209400 , 7987028543
  • 🌐 www.myjava.in
FacebookGoogle +TwitterYouTube

MyJava - java Training Institute