This week's giveaway is in the Spring forum.
We're giving away four copies of Learn Spring Security (video course) and have Eugen Paraschiv on-line!
See this thread for details.
Win a copy of Learn Spring Security (video course) this week in the Spring forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Super and Sub class

 
Argm Mastoi
Ranch Hand
Posts: 35
  • 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
  • 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
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
very good work with small window. I understood the situation thanx.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic