This week's book giveaway is in the Design forum.
We're giving away four copies of Design for the Mind and have Victor S. Yocco on-line!
See this thread for details.
Win a copy of Design for the Mind this week in the Design forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Constructor doubt - K&B Book

 
Jay Pawar
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
 
Joe Borderi
Ranch Hand
Posts: 151
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 1862
Firefox Browser Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
This constructor is recursive.
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic