answersLogoWhite

0


Best Answer

Inheritance is one of the building blocks of Java and it is used extensively in all java based applications. Inheritance is everywhere in Java. I can't think of one java project that I worked on, where inheritance wasn't used.

Inheritance is the feature wherein the properties/qualities of a parent class or interface is used in the child class. Both Classes & Interfaces are used in Java Inheritance

User Avatar

Wiki User

11y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

13y ago

Hierarchical Inheritance is also known as Multi-Level Inheritance.

Multilevel Inheritance

A Scenario where one class is inheriting/extending the bahavior of another class which in turn is inheriting behavior from yet another class.

Ex: public class Automobile {…}

Public class Car extends Automobile {…}

Public class Ferrari extends Car {…}

This multilevel inheritance actually has no limitations on the number of levels it can go. So as far as java goes, it is limitless. But for maintenance and ease of use sakes it is better to keep the inheritance levels to a single digit number.

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

Actually, java does not support multiple inheritance. You can achieve partial multiple inheritance using interfaces but java is not like C or C++ where you can do direct multiple inheritance. However, you can achieve partial multiple inheritance with the help of interfaces.

Ex: public class FerrariF12011 extends Ferrari implements Car, Automobile {…}

And this is under the assumption that Car and Automobile are interfaces.

Here if you see, though you don't inherit concrete code from the Car or the Automobile interface, you do inherit skeleton methods that determine the way your class eventually behaves and hence this can be considered partial Multiple Inheritance

This answer is:
User Avatar

User Avatar

Wiki User

12y ago

Actually, java does not support multiple inheritance. You can achieve partial multiple inheritance using interfaces but java is not like C or C++ where you can do direct multiple inheritance. However, you can achieve partial multiple inheritance with the help of interfaces.

Ex: public class FerrariF12011 extends Ferrari implements Car, Automobile {…}

And this is under the assumption that Car and Automobile are interfaces.

Here if you see, though you don't inherit concrete code from the Car or the Automobile interface, you do inherit skeleton methods that determine the way your class eventually behaves and hence this can be considered partial Multiple Inheritance

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

Single Inheritance

A Scenario where one class is inheriting/extending the behavior of just one super class.

Ex: public class Ferrari extends Car {…}

This answer is:
User Avatar

User Avatar

Niyaz Ahamed

Lvl 3
2y ago

Java is not support multiple inheritance, but we can able to achieve it by using interface and abstract class concept.

This answer is:
User Avatar
User Avatar

Emmanuel Ward

Lvl 1
2y ago
thanx

User Avatar

Wiki User

8y ago

Java doesn't support multiple inheritance.

This answer is:
User Avatar

User Avatar

Wiki User

13y ago

Java does not support multiple inheritance

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Java program to demonstrate multiple inheritance?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Related questions

What is ambiguity in multiple inheritance?

Java does not support multiple inheritance


How can you write multiple inheritance program in java?

Java does not support direct multiple inheritance. You can implement partial multiple inheritance using interfaces. ex: public class ExMultInherit implements interface1, interface2, interface 3 { ... .... ...... }


What does java not support?

Java does not support multiple inheritance.......


Give the structure of multiple inheritance?

Java does not support multiple inheritance. It is done with the help of interfaces in java. a class can implement n number of interfaces, thus showing multiple inheritance. but a class cannot extend multiple classes in java.


What is problem in multiple inheritance?

Java does not support direct multiple Inheritance. Harder to implement, not every language support it: C++ does, Java does not.


What kind of inheritance is not allowed in java?

Java does not allow the multiple inheritance of concrete classes, though it does allow a "hybrid" inheritance of one concrete class and multiple interfaces.


How ploymorphism and inheritance is different from that in Java and c plus plus?

C++ allows multiple inheritance while Java does not. In my opinion, multiple inheritance is not useful because it can get very confusing very quick. For polymorphism, C++ does early binding by default, while Java does late binding by default. Late binding is more useful than early binding.


Why you neet interface in java?

When you need the benefits of multiple inheritance while avoiding the DDD (Deadly Diamond of Death). Java doesn't allow multiple inheritance anyway.


What do you mean by multithread program in java?

A Program in Java that spawns multiple threads is called a multithreaded program in Java.


Can we implement multiple inheritance in java using package and interface?

Yes. Java does not support full fledged/proper multiple inheritance. But, whatever partial inheritance that Java supports can be implemented using interfaces Actually, java does not support multiple inheritance. You can achieve partial multiple inheritance using interfaces but java is not like C or C++ where you can do direct multiple inheritance. However, you can achieve partial multiple inheritance with the help of interfaces. Ex: public class FerrariF12011 extends Ferrari implements Car, Automobile {…} And this is under the assumption that Car and Automobile are interfaces. Here if you see, though you don't inherit concrete code from the Car or the Automobile interface, you do inherit skeleton methods that determine the way your class eventually behaves and hence this can be considered partial Multiple Inheritance.


Need of interface in java?

Interfaces are used in Java to accomplish most of the goals of Multiple Inheritance. For several reasons, Java only supports Single Inheritance for classes - i.e. a class can have only a single parent. The use of Interfaces is how Java attempts to implement most of the positives of the concept of Multiple Inheritance while avoiding its pitfalls.


What is multiple inheritance in java?

Actually, java does not support multiple inheritance. You can achieve partial multiple inheritance using interfaces but java is not like C or C++ where you can do direct multiple inheritance. However, you can achieve partial multiple inheritance with the help of interfaces. Ex: public class FerrariF12011 extends Ferrari implements Car, Automobile {…} And this is under the assumption that Car and Automobile are interfaces. Here if you see, though you don't inherit concrete code from the Car or the Automobile interface, you do inherit skeleton methods that determine the way your class eventually behaves and hence this can be considered partial Multiple Inheritance.