aspose file tools*
The moose likes Beginning Java and the fly likes Super and Sub class 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 » Java » Beginning Java
Bookmark "Super and Sub class" Watch "Super and Sub class" New topic
Author

Super and Sub class

Argm Mastoi
Ranch Hand

Joined: Oct 16, 2001
Posts: 35
hi,
how super class constructor is called when sub class constructor is called
Thanx
Fei Ng
Ranch Hand

Joined: Aug 26, 2000
Posts: 1242
for example...
class super {}
class sup extends super {}
the compiler will insert a default constructor for super
and sup right?? like this:
super(){} and sup(){}
but it will also insert super(); in sup() {} like this:
sup(){
super();
}
In your code if you write contructor yourself like
sup(){
....
....
}
compiler will insert super(); at the first line like this:
sup(){
super();
..
..
}
if you want u can put super(); in your contructor but it must
be at the firt line.
Hope this is clear, i have a small window which i can't see
what i typed.
Argm Mastoi
Ranch Hand

Joined: Oct 16, 2001
Posts: 35
very good work with small window. I understood the situation thanx.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Super and Sub class