Others fail on account of an issue often called information
ultra keto 360 overload, which means that you've so much information about weight loss dieting and exercising that you are unable to start. You would like only one extra day to analyze as well as try to make the perfect program. While nothing at all is wrong with studying weight loss and fitness, it's more important to get started. Get started now and as soon as you discover an innovative or more desirable method, make improvements to your dieting.
In other words when one object (child) holds all the properties of another object (parent) is called inheritance.
extend keyword is used to derive the class properties.
A term used in Inheritance concepts:-
Subclass (child class):- it is a class that inherits another class. It is also called “derived class”.
Superclass (parent class):- it is also class from where derived class inherits the property.
Types of Inheritance:-
1) Single inheritance:-
Example-
class Fruits {
void M1()
{
System.out.println("M1");
}
}
class Mango extends Fruits
{
void M2() {
System.out.println("M2");
} }
class Mask{ public static void main(String args[])
{
Mango m=new Mango();
m.M1();
m.M2();
}
}
Output- M1 M2
2) Multilevel Inheritance:-
Example-
class Multilevel
{
void M1()
{
System.out.println("M1");
}
}
class child1 extends Multilevel
{
void M2(){
System.out.println("M2");
}
}
class child2 extends child1{
void M3(){
System.out.println("M3");
}
}
class child3 extends child2{
void M4(){
System.out.println("M4");
}
}
class More{
public static void main(String[] args) {
child3 c=new child3();
c.M3();
c.M2();
c.M1();
c.M4();
}
Output-
M3 M2 M1 M4
3)Multiple Inheritance:-
4) Hierarchical Inheritance:-
Example-
class Flowers {
void M1()
{
System.out.println("M1");
}
}
class Dog extends Flowers{
void M2()
{
System.out.println("M2");}
}
class Cat extends Flowers{
void M3()
{
System.out.println("M3");}
}
class Dav
{ public static void main(String args[]) { Cat c=new Cat(); c.M3(); c.M1(); Dog d=new Dog(); d.M2(); d.M1(); } } Output- M3 M1 M2 M1
5) Hybrid Interface:-
Liked By
Write Answer
What is inheritance in Java?
We use cookies to ensure you have the best browsing experience on our website. By using our site, you
acknowledge that you have read and understood our
Cookie Policy &
Privacy Policy
Join MindStick Community
You have need login or register for voting of answers or question.
ultra keto 360
17-Jul-2019Others fail on account of an issue often called information ultra keto 360 overload, which means that you've so much information about weight loss dieting and exercising that you are unable to start. You would like only one extra day to analyze as well as try to make the perfect program. While nothing at all is wrong with studying weight loss and fitness, it's more important to get started. Get started now and as soon as you discover an innovative or more desirable method, make improvements to your dieting.
https://fairsupplement.com/ultra-keto-360/
Rahul Roi
15-Jul-2019Inheritance;-
Types of Inheritance:-
Inheritance;-
A term used in Inheritance concepts:-
Subclass (child class):- it is a class that inherits another class. It is also called “derived class”.
Superclass (parent class):- it is also class from where derived class inherits the property.
Types of Inheritance:-
1) Single inheritance:-
Example-
2) Multilevel Inheritance:-
Example-
class Multilevel { void M1() { System.out.println("M1"); } } class child1 extends Multilevel { void M2(){ System.out.println("M2"); } } class child2 extends child1{ void M3(){ System.out.println("M3"); } } class child3 extends child2{ void M4(){ System.out.println("M4"); } } class More{ public static void main(String[] args) { child3 c=new child3(); c.M3(); c.M2(); c.M1(); c.M4(); } Output- M3M2
M1
M4
3)Multiple Inheritance:-
4) Hierarchical Inheritance:-
Example-
5) Hybrid Interface:-