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