29 September, 2020

Write a java program for Hierarchical Inheritance.

java inheritance tutorial,inheritance in java tutorial,java inheritance,inheritance java,inheritance in java,java inheritance example,java inheritance example code,how to use inheritance in java,inheritance java thenewboston,inheritance,object oriented programming in java,java programming,single inheritance,hierarchical inheritance,oop,programming,java fundamentals,object oriented programming
class Animal
{
	void Walk()
	{
		System.out.println("Animal can Walk");
	}
}
class Man extends Animal
{
	void Walk()
	{
		System.out.println("Man can Walk using Two lags");
	}
	public static void main(String ar[])
	{
		Man m=new Man();
		m.Walk();
	}
}
class Lion extends Animal
{
	void Walk()
	{
		System.out.println("Lion can Walk using Four lags");
	}
	public static void main(String ar[])
	{
		Lion L=new Lion();
		L.Walk();
	}
}
class Dog extends Animal
{
	void Walk()
	{
		System.out.println("Dog can Walk using Four lags");
	}
	public static void main(String ar[])
	{
		Dog d=new Dog();
		d.Walk();
	}
}
26
NEXT ARTICLE Next Post
PREVIOUS ARTICLE Previous Post
NEXT ARTICLE Next Post
PREVIOUS ARTICLE Previous Post