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  >  Interview Questions  >  J2EE  >  Java
Go To First  |  Previous Question  |  Next Question 
 Java  |  Question 99 of 921    Print  
Does a class inherit the constructors of its superclass
A class does not inherit constructors from any of its superclasses.


  
Total Answers and Comments: 8 Last Update: April 04, 2008   
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
July 29, 2007 05:43:29   #1  
sujatham Member Since: January 2006   Contribution: 142    

RE: Does a class inherit the constructors of its super...
No.The class cannot inherit the constructors of its super class.
 
Is this answer useful? Yes | No
December 11, 2007 09:00:00   #2  
onalennadaniel Member Since: December 2007   Contribution: 1    

RE: Does a class inherit the constructors of its superclass

no


 
Is this answer useful? Yes | No
December 16, 2007 13:00:23   #3  
gerald.amalraj Member Since: December 2007   Contribution: 8    

RE: Does a class inherit the constructors of its superclass

I think yes. there are two ways to access the super class constructors they are :


First Method:

class A
  {
    A()
          {
          System.out.println(" First Message ");  
       }
      
   }
  
   class B extends A
  {
 
     B()
       {
       System.out.println(" Second Message ");
       }
   
  public static void main(String a[])
    {
   
       B b=new B();
    }
 }  

Second Method:Thr Super

class A
  {
   double wid;
   double hei;
   double dep;

     A(double w,double h,double d)
      {
    wid=w;
    hei=h;
    dep=d;
   }


   }

class B extends A
  {
double wei;

     B(double w,double h,double d,double m)
      {
    super(w,h,d);
    wei =m;


   }

   double vol()
       {
        return wid*hei*dep*wei;
    }


   }
class C
 {
  public static void main(String a[])
    {

        B b=new B(2.0, 2.0, 2.0,2.0);

        System.out.println(" >>>>>  " +b.vol());

    }
 } 


 
Is this answer useful? Yes | No
January 06, 2008 13:57:28   #4  
Mithun Challa Member Since: January 2008   Contribution: 6    

RE: Does a class inherit the constructors of its superclass
No it does not inherit the constructor of the superclass. however when you create a object of subclass the constructor of the superclass is called first and then the constructor of sub class is called
 
Is this answer useful? Yes | No
February 13, 2008 04:58:30   #5  
vijayashanti Member Since: February 2008   Contribution: 1    

RE: Does a class inherit the constructors of its superclass
A class does inherit the constructor of superclass using super() method
 
Is this answer useful? Yes | No
February 13, 2008 05:45:55   #6  
sampra Member Since: February 2008   Contribution: 279    

RE: Does a class inherit the constructors of its superclass
yes it can but by using corrosponding super class  
 
Is this answer useful? Yes | No
February 14, 2008 04:07:41   #7  
shaik subhani Member Since: December 2007   Contribution: 11    

RE: Does a class inherit the constructors of its superclass
A super default constructor is automatically available to the subclass , when the subclass object is created. but if you want to access super class parameterized constructors , we must use super keyword.
 
Is this answer useful? Yes | No
April 04, 2008 03:18:08   #8  
manjunathboya Member Since: March 2008   Contribution: 2    

RE: Does a class inherit the constructors of its superclass
 yes, the super class inherit the construtor. we can call the super class by

            using the SUPER keyword.

 
Is this answer useful? Yes | No


 
Go To Top


 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