File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/file-tools
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Object construction

 
John Paverd
Ranch Hand
Posts: 115
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I have turned a mistake I made into a mock exam question. I hope that you are either amused if you know the answer to the question below, or informed if you didn't.

What is the result?
a. Compile error
b. Run time error
c. Compiles and runs fine, but produces no output.
 
Sridhar Srikanthan
Ranch Hand
Posts: 366
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
John,
Thats an interesting question. I guessed the answer but checked it just in case
On working more on your code, I have a strange code here. I dont know how it works but anybody is free to interpret this

The result of this code is
Hello A constructor (prints only once)
I thought this should print infinitely because we are instantiating a B object in A's constructor and this will in turn invoke A's constructor because A is its superclass
Am I missing something?
Thanks in advance,
Sri :roll:
 
jason stark
Greenhorn
Posts: 10
  • 0
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had it running infinatly when I tested it
Jason
 
Don't get me started about those stupid light bulbs.
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic