• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Default Constructor

 
pop
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
Can anyone prove that default constructors are created for you by the compiler (through code)
 
Jason Fox
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator


Subclass will throw an error stating: cannot resolve constructor SuperClass() in class SubClass. This is because the compiler has inserted the default constructor:


If you add an empty constructor to SuperClass, or write your own constructor that passes an int to SuperClass, then it compiles correctly. I hope this helps.
 
Michael Yuan
author
Ranch Hand
Posts: 1427
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This sounds like a homework question ... And it has almost nothing to do with J2ME.
 
Jason Fox
Ranch Hand
Posts: 114
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You've got a point, maybe I shouldn't have answered. Is there a guideline as to what questions are appropriate, and how to spot homework assignments? No offense intended to the original poster, especially if this wasn't an assignment.
 
Michael Yuan
author
Ranch Hand
Posts: 1427
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi Jason,

I think the best way to answer this type of questions is to give "hints" and small code fragments but not complete answers which people can copy and paste. Thanks a lot.

cheers
Michael
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic