ALLInterview.com :: Home Page KalAajKal.com
 Advertise your Business Here     
Browse  |   Placement Papers  |   Company  |   Code Snippets  |   Certifications  |   Visa Questions
Post Question  |   Post Answer  |   My Panel  |   Search  |   Articles  |   Topics  |   ERRORS new
   Refer this Site  Refer This Site to Your Friends  Site Map  Bookmark this Site  Set it as your HomePage  Contact Us     Login  |  Sign Up                      
info       Did you received any Funny E-Mails from your Friends and like to share with rest of our friends? Yeah!! you can post that stuff   HERE
Google
 
Categories  >>  Software  >>  Core Java  >>  Java J2EE  >>  Java Related
 
 


 

 
 Core Java interview questions  Core Java Interview Questions
 Advanced Java interview questions  Advanced Java Interview Questions
 Swing interview questions  Swing Interview Questions
 EJB interview questions  EJB Interview Questions
 Servlets interview questions  Servlets Interview Questions
 Struts interview questions  Struts Interview Questions
 JDBC interview questions  JDBC Interview Questions
 JMS interview questions  JMS Interview Questions
 SunOne interview questions  SunOne Interview Questions
 J2EE interview questions  J2EE Interview Questions
 Weblogic interview questions  Weblogic Interview Questions
 Websphere interview questions  Websphere Interview Questions
 Java Networking interview questions  Java Networking Interview Questions
 Java J2EE AllOther interview questions  Java J2EE AllOther Interview Questions
Question
How multipleInheritance is possible in java?
 Question Submitted By :: Aruna ,sridevi
I also faced this Question!!     Rank Answer Posted By  
 
  Re: How multipleInheritance is possible in java?
Answer
# 1
Through Interfaces.........
 
Is This Answer Correct ?    3 Yes 0 No
Firdouse
 
  Re: How multipleInheritance is possible in java?
Answer
# 2
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 ?    2 Yes 0 No
Aruna
 
 
 
  Re: How multipleInheritance is possible in java?
Answer
# 3
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 ?    0 Yes 0 No
Harikrishna
 
  Re: How multipleInheritance is possible in java?
Answer
# 4
in java multiple inheritance is possible using interface.
 
Is This Answer Correct ?    0 Yes 1 No
Anurekha
 
  Re: How multipleInheritance is possible in java?
Answer
# 5
In Java multiple inheritance is not Possible....
Don't think that interface is for multiple inheritance ,most
of the book given wrong idea about - interface is for 
multiple inheritance .
 
Is This Answer Correct ?    0 Yes 0 No
Suneel
 
  Re: How multipleInheritance is possible in java?
Answer
# 6
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 ?    1 Yes 2 No
Namrta
 
  Re: How multipleInheritance is possible in java?
Answer
# 7
manoj
 
Is This Answer Correct ?    1 Yes 1 No
Kumar
 
  Re: How multipleInheritance is possible in java?
Answer
# 8
Yes ,  Namarata U r answer is write.....!! 
I am agree with this satements .
 
Is This Answer Correct ?    0 Yes 2 No
Sidhu
 
  Re: How multipleInheritance is possible in java?
Answer
# 9
yes, Namratha u r correct, i got u r point
 
Is This Answer Correct ?    0 Yes 2 No
N D Rao
 
  Re: How multipleInheritance is possible in java?
Answer
# 10
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
Uthrakumar-wipro Technologies
 
  Re: How multipleInheritance is possible in java?
Answer
# 11
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
Gopi
 
  Re: How multipleInheritance is possible in java?
Answer
# 12
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
Gangadhar
 
  Re: How multipleInheritance is possible in java?
Answer
# 13
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
Pradeep Panwar
 
  Re: How multipleInheritance is possible in java?
Answer
# 14
java does nt support multiple interface by using interfaces
its support tis one
 
Is This Answer Correct ?    0 Yes 0 No
Shiva
 
  Re: How multipleInheritance is possible in java?
Answer
# 15
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
Archana
 
  Re: How multipleInheritance is possible in java?
Answer
# 16
Yes...Gopi u r answer is right.... i am agree with u
 
Is This Answer Correct ?    0 Yes 0 No
Vishal
 

 
 
 
Other Core Java Interview Questions
 
  Question Asked @ Answers
 
what is servlet filter?  1
What are MalformedURLException and UnknownHost Exceptions and whey they will be thrown?  1
What is the immediate superclass of Menu?  1
Is multiple inheritance allowed in Java? Why ?  5
Which class has no duplicate elements?  8
What are the OOAD concepts in java explain with examples? Aricent4
Name the method that used to clear the buffer ?  2
how to minimize the functionality to will not force garbage collector?  2
what is meant by string pooling? Wipro6
If I have 1000 objects and my requirement is to sort them quickly, then which collection would you recommend and why? KPIT3
why java not supproting multiple inheritance?  5
I/O blocking means?  1
how to use this key word in java programming?  5
what is stringtolennizer with example? Symphony1
What is casting?  3
what is jms? features of jms CTS1
What is the range of the char type?  2
I have a String s = java; What is the output when I say s.replaceAll('j', 'k'); Also what is the value of s after replacing? KPIT5
Program to find greatest prime number in n numbers? Huawei3
What are the steps to do connection pooling in weblogic? TCS1
 
For more Core Java Interview Questions Click Here 
 
 
 
 
 
   
Copyright Policy  |  Terms of Service  |  Help  |  Site Map 1  |  Articles  |  Site Map  |   Site Map  |  Contact Us interview questions urls   External Links 
   
Copyright © 2007  ALLInterview.com.  All Rights Reserved.

ALLInterview.com   ::  Forum9.com   ::  KalAajKal.com