File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Object construction Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Object construction" Watch "Object construction" New topic

Object construction

John Paverd
Ranch Hand

Joined: Nov 17, 2002
Posts: 115
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.

SCJP 1.4
Sridhar Srikanthan
Ranch Hand

Joined: Jan 08, 2003
Posts: 366
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

Joined: Dec 01, 2002
Posts: 10
I had it running infinatly when I tested it
I agree. Here's the link:
subject: Object construction
It's not a secret anymore!