File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Super and Sub class

 
Argm Mastoi
Ranch Hand
Posts: 35
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi,
how super class constructor is called when sub class constructor is called
Thanx
 
Fei Ng
Ranch Hand
Posts: 1244
1
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 35
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
very good work with small window. I understood the situation thanx.
 
It is sorta covered in the JavaRanch Style Guide.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic