permaculture playing cards*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Multiple inheritance (cannot reference name before supertype constructor has been called) Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of The Java EE 7 Tutorial Volume 1 or Volume 2 this week in the Java EE forum
or jQuery UI in Action in the JavaScript forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Multiple inheritance (cannot reference name before supertype constructor has been called)" Watch "Multiple inheritance (cannot reference name before supertype constructor has been called)" New topic
Author

Multiple inheritance (cannot reference name before supertype constructor has been called)

deepu bhadriraju
Greenhorn

Joined: Aug 01, 2012
Posts: 12
[Added code tags - see UseCodeTags for details]

please help me out
I am getting the error in child class class constructor i.e in super(name,dd,mm,yyyy,salary)
cannot reference name before supertype constructor has been called
cannot reference dd before supertype constructor has been called
cannot reference mmbefore supertype constructor has been called
cannot reference yyyy before supertype constructor has been called


Seetharaman Venkatasamy
Ranch Hand

Joined: Jan 28, 2008
Posts: 5575

Let's take this example which is simplified version of your problem


you are trying to pass str which is not yet initialized to super constructors.
note: subclass constructor runs *only* successful of super class constructors
deepu bhadriraju
Greenhorn

Joined: Aug 01, 2012
Posts: 12
Seetharaman Venkatasamy wrote:Let's take this example which is simplified version of your problem


you are trying to pass str which is not yet initialized to super constructors.
note: subclass constructor runs *only* successful of super class constructors





Sorry cant get you .can you make necessary changes to my code please
dennis deems
Ranch Hand

Joined: Mar 12, 2011
Posts: 808
deepu bhadriraju wrote:
deepu bhadriraju
Greenhorn

Joined: Aug 01, 2012
Posts: 12
Dennis Deems wrote:
deepu bhadriraju wrote:

Name ,dd,mm,salary refer to variable of grand-parent class..I rectified my mistake.what iam trying to make call the super class constructor without assigning values to it
NOW changed code is
public Trainee(int m1, int m2, int m3,String name,int dd,int mm,int yyyy,int salary)
{
super(name, dd, mm, yyyy,salary);
this.m1 = m1;
this.m2 = m2;
this.m3 = m3;
}

 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Multiple inheritance (cannot reference name before supertype constructor has been called)