GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Interview Questions  >  J2EE  >  Core Java
Go To First  |  Previous Question  |  Next Question 
 Core Java  |  Question 145 of 493    Print  
why java does not support inheritance of multiple superclasses?
what is achieved by inheritance?
why there is no main method in servlets/jsps?

  
Total Answers and Comments: 10 Last Update: August 18, 2006     Asked by: manoj raut 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
October 27, 2005 12:30:21   #1  
refy        

RE: why java does not support inheritance of multiple ...
java does not support multiple inheritance
 
Is this answer useful? Yes | No
October 28, 2005 01:53:02   #2  
uday        

RE: why java does not support inheritance of multiple ...

Handling the two classes always be a problem.Why we need to extends two classes at a time.If that required use two extends statements.Like this...

Class A extends B

{

......

}

class c extends A

{

}

problem cleared...


 
Is this answer useful? Yes | No
October 29, 2005 02:32:59   #3  
amit raj        

RE: why java does not support inheritance of multiple ...
Actually java can extends only one class ie it does not support multiple inheritance but itsupports it as an substitute ie inreface.Servlet/JSP are the server side programming language and running this program we need only server not a main coz it is not a executable program.
 
Is this answer useful? Yes | No
November 06, 2005 14:54:13   #4  
srikanthboddu        

RE: why java does not support inheritance of multiple ...
supporting multiple inheritance in java is tedious b'case if u defined a method with the same signature in the two super classes when u invoke that method by using the sub class object it leads confusion to which super class method to invoke
 
Is this answer useful? Yes | No
November 11, 2005 16:19:29   #5  
mandyjoshi Member Since: November 2005   Contribution: 20    

RE: why java does not support inheritance of multiple ...

A1.

Consider following example

class A { method XYZ(//some implementation)}

class B { method XYZ(//some implementation)}

class C extends A,B

Now if you say C c = new C() and C.XYZ() java don't undestand which implementation to use.

A2.

Inheritance achieves structure, reusable code

A3.

main() method is required to start new java process. In servlet,JSP (which are just class not process) container is responsible for life cycle of both. Container itself is part of some running process.


 
Is this answer useful? Yes | No
January 25, 2006 08:39:48   #6  
Manish Mishra        

RE: why java does not support inheritance of multiple ...

sorry fren your answer is incorrect.... Java DO NOT SUPPORT MULTIPLE INHERITENCE, but we can implement it by implementing interfaces not like that u said... coz thats still called sngle inheritence.


 
Is this answer useful? Yes | No
March 24, 2006 06:32:01   #7  
Reshma Rout        

RE: why java does not support inheritance of multiple ...

If there will be multiple base classes,then the class which is extending from those base classes will be in ambiguity problem,this problem is named as Diamond problem.That's why Java doesn't support multiple inheritance.

We can create a new class including the properties of the previous class without destroying it.This is possible through inheritance only.

B'coz Servlets and JSP's are based on Client-Server architecture,and in this Server has to receive the request of the client through its Service() method and this is only the main method in Servlet \JSP(J2EE applications).


 
Is this answer useful? Yes | No
May 20, 2006 00:42:46   #8  
veds_21 Member Since: May 2006   Contribution: 1    

RE: why java does not support inheritance of multiple ...

hi all,

 suppose  we write  class C extends class B A

When are creating an object  of calss C ,then as we know before sub class's constructor is initialised ,the super class's  constructor should be initialised. Then at this moment the JVM will get confused to  initialise which super class's constructor  first either of class A or of calss B .

I think this is the basic problem for multiple inheritance through extend  keyword.

Bye  bye 

Vedabyasa Swain

Veds_21@yahoo.co.in


 
Is this answer useful? Yes | No
June 07, 2006 02:34:07   #9  
Nagapratap        

RE: why java does not support inheritance of multiple ...

Java doesnot support multiple inheritance to avoid situations that arise ambiguity. For Eg: If Class A contains a method : public void show(String s) and Class B also contains the method: public void show(String s). Let us assume a Class C extends both A and B and the method public void show(String s) is called on an object of C. There is an ambiguity as to which method is to be executed. To avoid such situations Java does not support multiple inheritance.

Through inheritance a class can obtain access to all the non-private members of its super class


 
Is this answer useful? Yes | No
August 18, 2006 01:50:23   #10  
Annapareddy SrinivasRao        

Why there is no MAIN() in Servlets & JSP's

Hi all!

It seems be good Q?

the answer is for this Q?

in my view ........

Beans( JAVA CLASSES)  are different from web componets ...( Servelts & JSPs)

web components always serves the web requests  means just getting the requests and process the request with the help of beans or some times them selves only .

here in Servlets "Service () " is working like a main ()

all the processing is directed from this funtion only and finally response will sent form this funtion only so it seems to be a main() in Beans .

So may the name is different but the functionality is same for Main() in Beans and Service() in Servlets..

we can say like this

this is my opinion , if there is any valid comments then i should accept .....

please feel free to send comments to my email id srinivas.annapareddy @ gmail.com


 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
Sponsored Links

 




About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape