How multipleInheritance is possible in java?
Answer Posted / pradeep panwar
Hi all, This is Pradeep...
I am confused by the java statement that "By using
interface we can achieve multiple inheritance bcoz java
doesn't support Multiple inheritance".
Yes.Ok java doent support Multiple inheritance. Now we know
that inheritance means that "one object acquires the
property of another object".
So how can it is possible achieve Multiple inheritance by
interface.
Interface that contains just undefined methods like below
code.
interface Member1
{
public void eye();
public void nose();
public void mouth();
}
interface Member2 extends member1
{
public void neck();
public void hand();
public void stomach();
}
interface Member3 extends Member1,Member2
{
public void leg();
}
class Man implements Member3
{
public man()
{
Member3 ref=new Man();
}
// Here Implements all 7 methods.
}
/*
Is the above code defines multiple Inheitance?
undefined methods are eye,nose,mouth,neck,handand stomach
are fall in Interface Member3 .Yes. But Inheritance means
that one object acquires the property of another
object.Property means that code and data.
In here, there is no code just declarations of method which
is not to be a code .
So How can we say interface achieve multiple inheritance.
Please any one explain and clear my doubt with simple
example.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
What is the length of a string?
How many types of memory areas are allocated by JVM in java?
What does microservices mean?
Can constructor be synchronized?
What is compiler and what its output.
What is the collections api in java programming?
how is final different from finally and finalize in java?
How many characters is 2 bytes?
What does three dots mean in java?
What is an immutable object?
What is keyword in oop?
Can you declare an interface method static?
Write the algorithm to check the number non-leaf nodes in a tree.
what is the volatile modifier for? : Java thread
Does java list allow null?