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

Real 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 Moreopen source free template for personal or company blogsLooking for perfect theme for personal or company blogs.Released under the MIT license, which means you can use this template for any purpose, even for commerci ...Read MoreHow to Build an App for the Google AssistantApps for the Google Assistant are the gateway for your users to engage with your services through Google Home, Android phones, iPhones.Watch here to build an as ...Read MoreIntroduction to AMP - Accelerated Mobile PagesAMP, short for Accelerated Mobile Pages, is new new open source initiative to make the mobile web awesome again.Watch Here the Introduction to AMP ...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