Why java does not support inheritance of multiple superclasses?what is achieved by inheritance?why there is no main method in servlets/jsps?

Showing Answers 1 - 10 of 10 Answers

refy

  • Oct 27th, 2005
 

java does not support multiple inheritance

  Was this answer useful?  Yes

uday

  • Oct 28th, 2005
 

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...

  Was this answer useful?  Yes

amit raj

  • Oct 29th, 2005
 

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.

  Was this answer useful?  Yes

srikanthboddu

  • Nov 6th, 2005
 

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

  Was this answer useful?  Yes

mandyjoshi

  • Nov 11th, 2005
 

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.

  Was this answer useful?  Yes

Manish Mishra

  • Jan 25th, 2006
 

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.

  Was this answer useful?  Yes

Reshma Rout

  • Mar 24th, 2006
 

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).

  Was this answer useful?  Yes

veds_21

  • May 20th, 2006
 

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

  Was this answer useful?  Yes

Nagapratap

  • Jun 7th, 2006
 

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

  Was this answer useful?  Yes

Annapareddy SrinivasRao

  • Aug 18th, 2006
 

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

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions