GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Tech FAQs  >  OOPS
Go To First  |  Previous Question  |  Next Question 
 OOPS  |  Question 217 of 255    Print  
can we call constructor of superclass directly without using super()method in subclass? if yes,explain,if no,why?

  
Total Answers and Comments: 4 Last Update: November 20, 2007     Asked by: lherwadkar 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
April 10, 2006 06:07:42   #1  
shrabani        

RE: can we call constructor of superclass directly wit...
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().


 
Is this answer useful? Yes | No
April 14, 2006 03:51:10   #2  
Mohammed Gooni        

RE: can we call constructor of superclass directly wit...

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


 
Is this answer useful? Yes | No
April 04, 2007 06:42:02   #3  
Sony V George        

RE: can we call constructor of superclass directly wit...

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


 
Is this answer useful? Yes | No
November 20, 2007 04:04:57   #4  
Ashok Agnihotri        

RE: can we call constructor of superclass directly wit...
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.

 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 
Sponsored Links

 




About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape