Hiwe have super class constructor and extends subclass which contains subclass constructor we create subclass obj only what’s result & what happens

Showing Answers 1 - 4 of 4 Answers

Hi,

I think the question is wrong. When we extend the super class then only a class becomes subclass of super class. Please reframe it properly.

Thanks

Naveen.

  Was this answer useful?  Yes

Radhakrishna

  • Nov 9th, 2006
 

hi,

By default the first statement of any constructor is the super();  means  before excuting the subclass constructor it will call the superclass zeroargument constructor.putting this statement in the subclass constructor is taken care by the compiler.after the excution of superclass zeroargument constructor the control will come back to the subclass constructor.

This belove example will help u for better understanding of this topic.

class superclass
{
 public superclass(){
  System.out.println("in the super class constructor");
 }
 
}
class subclass extends superclass
{
 public subclass(){
  System.out.println("in the subclass constructor");
 }
}

public class Test
{
 public static void main(String[] args){
  subclass obj=new subclass();

 }
 
}

  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