This week's giveaway is in the Java/Jakarta EE forum. We're giving away four copies of Java EE 8 High Performance and have Romain Manni-Bucau on-line! See Java instantiation. When you instantiate an object in Java you are instantiating a single object regardless of it's class hierarchy. Therefore in your example if you instantiate Servlet1 and Servlet2 you get a single instance of Servlet1 and another of Servlet2 with NO instances of BaseServlet.
Andy Bowes<br />SCJP, SCWCD<br />I like deadlines, I love the whoosing noise they make as they go flying past - Douglas Adams
posted 14 years ago
If i have some code in constructor of superclass, it gets executed as soon as I create object of its subclass. That means instance of superclass must be getting created.
Hi Ani Constructors r responsible for initialization of a class and not instantiation. So they r bound to get fired when subclass constructor is fired by which the members of the servlet gets initialized but the same instance is used throught. HIH Cheers Vishal