wood burning stoves*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Constructor doubt - K&B Book Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Constructor doubt - K&B Book" Watch "Constructor doubt - K&B Book" New topic
Author

Constructor doubt - K&B Book

Jay Pawar
Ranch Hand

Joined: Aug 27, 2004
Posts: 411
Hi all,
This is reference from chapter 5 Kathy and Bert book pg 325. Look at the code below.



The explanation given in the book says that some compiler might give error and sometime JVM could throw StackOverFlowError. I tried this code and I am getting compile time error saying "recursive constructor invocation".

My question is what should we select in the exam if we have both the options
a) Compile time error
b) Run-time error.

Any thoughts/suggestions ?

TIA


Cheers,<br />Jay<br /> <br />(SCJP 1.4)<br />Heights of great men were not achieved in one day, they were toiling day and night while their companions slept.
Joe Borderi
Ranch Hand

Joined: Oct 23, 2004
Posts: 151
You may see this as punting, but I really wouldn't worry about this question on the exam. Questions on the exam are very well tested and unambiguous. If the book gives you a question with "sometimes the answer is this... and sometimes the answer is that... " answer, the question won't be on the exam.

As a programmer, you should simply know and understand that the situation depicted in the question is something you don't want to do.
Krishna Srinivasan
Ranch Hand

Joined: Jul 28, 2003
Posts: 1844

This constructor is recursive.


Krishna Srinivasan
Spring Tutorials, OCAJP Mock Questions, 400+ OCPJP Mock Questions
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: Constructor doubt - K&B Book
 
Similar Threads
Which constructor is being called?
Superclass Constructor calling from subclass
Default Constructor
Overloaded constructors...
Construcors with Inheritance