How multipleInheritance is possible in java?

Answers were Sorted based on User's Feedback



How multipleInheritance is possible in java?..

Answer / firdouse

Through Interfaces.........

Is This Answer Correct ?    6 Yes 0 No

How multipleInheritance is possible in java?..

Answer / aruna

Mr.Firdouse,I know that it is possible through interfaces
but i want to know how it is implemented?Can u give me a
clear answer?

Is This Answer Correct ?    3 Yes 0 No

How multipleInheritance is possible in java?..

Answer / harikrishna

Hi, Aruna how r u doing?

In Java multiple inhritance provided through interfaces
by extending morethan one interface. We can extend more
than one class in C++. But this is not possible in java
that's why java doesn't support mutiple inhritance
directly.
public interface GroupedInterface extends Interface1,
Interface2,
Interface3

An interface can extend other interfaces, just as a class
can extend or subclass another class. However, whereas a
class can extend only one other class, an interface can
extend any number of interfaces. The interface declaration
includes a comma-separated list of all the interfaces that
it extends.
Aruna if you still not understood please
go through
http://java.sun.com/docs/books/tutorial/java/IandI/createint
erface.html this site. if you understad it' good. give me
feed back.
Thanq

Is This Answer Correct ?    3 Yes 0 No

How multipleInheritance is possible in java?..

Answer / archana

i agree with the answer tat multiple inheritance is
achieved by interfaces,
but the question is

WHAT IF TWO INTERFACES HAVING SAME METHODS THEN WHAT METHOD
IS USED IN CLASSES WHO IS IMPLEMENTING THE INTERFACES?

Is This Answer Correct ?    1 Yes 0 No

How multipleInheritance is possible in java?..

Answer / namrta

Multiple Inheritance is not at all posiible in Java.
Reason: Inheritance means reusability of code and
Interfaces are just the declaration of methods not
implementation.We have to write code for methods for the
interface in class which is implementing that Interface.

Is This Answer Correct ?    2 Yes 2 No

How multipleInheritance is possible in java?..

Answer / kumar

manoj

Is This Answer Correct ?    1 Yes 1 No

How multipleInheritance is possible in java?..

Answer / uthrakumar-wipro technologies

multiple inheritance is not possible in java but we can
apply the multiple inheritance concept using interfaces in
java but it doesn't meant that java will support multiple
inheritance rather we can implement the idea of multiple
inheritance as follows......


eg:

<class name> implements <class1>,<class2>,...
{
}



but the interface technique will not gives the
exact definition of multiple inheritance.....

Is This Answer Correct ?    0 Yes 0 No

How multipleInheritance is possible in java?..

Answer / gopi

Namrata what i am telling is,multiple inheritence is not
possible in java.that is every body knows but the thing is,
in c++ while the time of multiple inheritance ambiguity is
happened.like if u have same methods in all extended classes
while the time execution ambiguity will happen.but in the case
of interfaces in java even though u have same methods in all
interfaces there s no ambiguity at execution.for avoiding this
ambiguity in c++ we are using virtual keyword.
ofcourse ur correct.but internally interfaces are satisfied
the multiple interfaces concept.

Is This Answer Correct ?    0 Yes 0 No

How multipleInheritance is possible in java?..

Answer / gangadhar

See gopi what namrata said is exactly correct,
in java Interfaces r given for Polymorphism not multiple
inheritance.
more over Inheritance means:the super class object is sub
object to sub class,but when u going through interfaces we
r not creating object directly. so come super class object
is sub object to sub class object.

my conclusion is java doesn't support multiple inheritance

Is This Answer Correct ?    0 Yes 0 No

How multipleInheritance is possible in java?..

Answer / 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

More Core Java Interview Questions

What is string data type?

0 Answers  


What defines function?

0 Answers  


What is getkey () in java?

0 Answers  


Can an anonymous class be declared as implementing an interface and extending a class in java programming?

0 Answers  


what is java bean?where can we use it?

12 Answers   TCS,






What is a blocking method in Java?

0 Answers  


what is the use of finalize()Method please explain with an example

3 Answers  


What’s a deadlock?

0 Answers  


What is OOP's Terms with explanation?

0 Answers  


How can a gui component handle its own events in java programming?

0 Answers  


why applet doesn't have main? isn't possible a program with out main?

9 Answers   TCS,


What are the uses of java?

0 Answers  


Categories