• Post Reply Bookmark Topic Watch Topic
  • New Topic

plz rectify the err in prgm  RSS feed

 
Mahesh Pinnamaneni
Ranch Hand
Posts: 100
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hai friends ,
#1)could u plz tell me why this has failed at line 2
class A {A(int i) {}} // 1
class B extends A {} // 2
plz explain me clearly,
cheers,
Mahesh
 
Julian Kennedy
Ranch Hand
Posts: 823
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What did it fail with? java.mung.PointlessCodeException?
 
Ram Rajan
Greenhorn
Posts: 5
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Originally posted by Mahesh Pinnamaneni:
hai friends ,
#1)could u plz tell me why this has failed at line 2
class A {A(int i) {}} // 1
class B extends A {} // 2
plz explain me clearly,
cheers,
Mahesh


This is because
First line of every constructor has to be
a call to either super constructor or this().
If you did not code a super constructor call, the compiler
automatically adds a call to super() for you (this happens in the background during compile)

To fix this either :
1) Add an explicit call to super(int i) from your default constructor in B.
or
2) Add a no-arg constructor to A i.e A()

I would advice getting Kathy's book
Also please post such questions in the beginners board.
[ September 09, 2004: Message edited by: Ram Rajan ]
 
s choukse
Greenhorn
Posts: 27
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
just add a default constructor to Class A .
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!