This week's book giveaways are in the Java EE and JavaScript forums.
We're giving away four copies each of The Java EE 7 Tutorial Volume 1 or Volume 2(winners choice) and jQuery UI in Action and have the authors on-line!
See this thread and this one for details.
The moose likes Java Micro Edition and the fly likes Default Constructor 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 » Mobile » Java Micro Edition
Bookmark "Default Constructor" Watch "Default Constructor" New topic
Author

Default Constructor

pop
Greenhorn

Joined: Jul 20, 2004
Posts: 2
Hi,
Can anyone prove that default constructors are created for you by the compiler (through code)


Prakash Sahu
Jason Fox
Ranch Hand

Joined: Jan 22, 2004
Posts: 114


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

Joined: Mar 07, 2002
Posts: 1427
This sounds like a homework question ... And it has almost nothing to do with J2ME.


Seam Framework: http://www.amazon.com/exec/obidos/ASIN/0137129394/mobileenterpr-20/
Ringful: http://www.ringful.com/
Jason Fox
Ranch Hand

Joined: Jan 22, 2004
Posts: 114
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

Joined: Mar 07, 2002
Posts: 1427
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
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Default Constructor