Can we call constructor of superclass directly without using super()method in subclass? if yes,explain,if no,why?

Questions by lherwadkar

Showing Answers 1 - 8 of 8 Answers

shrabani

  • Apr 10th, 2006
 

NO....

it's very bad design, if you are calling constructor of super class from sub class.

child is calling parent class method, so child has to use super().

  Was this answer useful?  Yes

Mohammed Gooni

  • Apr 14th, 2006
 

No

But according to me if we dont write the super() in Sub Class then also by default  it is used in the first line of the subclass constructors.

If the super() is not written in the subclasses then no constructors of super classes is loaded in memory and then we cannot create an instance of the subclasses.

Tell me if this concept is right

  Was this answer useful?  Yes

Sony V George

  • Apr 4th, 2007
 

yes we can call by simpy Intilizing the Object of the sub class. Intrernally the default contrutor will call the super class . if there is no construtor declerd with parameter.

if any contrutor declared with parameter the we need to call super class construtor explicetly ,bypassing paremater . It should be the first line of the sub class construtor

  Was this answer useful?  Yes

Ashok Agnihotri

  • Nov 20th, 2007
 

it's happened by default. if we create the object of subclass the it will implicitly or accordingly call the super class constructor.

class A{
   A(){}
}
class B extends A{
   B(){}
}

public class C {
   public static void main(Strinng args[]){
      B obj = new B();
}
}

in the above code , when obj is created constructor of A is called automatically.

  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