Java J2ee interview questions and answers: – From the below java code which constructor will fire first?

You can see our Java J2ee interview question videos from

Ok, the first thing, let’s try to understand the above java interview question.  Let’s say you have two classes one is parent class and the other is a child class which extends (inherits) from the parent class as shown in the below code. Now if you create the object of “Child” class which constructor will fire first.

 class Parent


public Parent()


System.out.println(“This is parent”);



class Child extends Parent


public Child()


System.out.println(“This is Child”);



The answer is first the Parent class constructor will get executed and then the child class constructor will fire.

One more  Java j2ee interview question which was recently asked  to one of my friend was :-  Does Stringbuffer always give better performance as compared to string.

See the following video on By using String or String Buffer performance increases:-

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s