This week's book giveaway is in the Jobs Discussion forum.
We're giving away four copies of Java Interview Guide and have Anthony DePalma on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Guess what this prints... Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login

Win a copy of Java Interview Guide this week in the Jobs Discussion forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Guess what this prints..." Watch "Guess what this prints..." New topic

Guess what this prints...

Hemal Mehta
Ranch Hand

Joined: Nov 16, 2000
Posts: 101

and why ofcourse?
Also what steps will the toString method be executed 3 times by the compiler?
[ Jess added UBB [code] tags to preserve whitespace, check 'em out! ]
[ January 30, 2003: Message edited by: Jessica Sant ]
John Paverd
Ranch Hand

Joined: Nov 17, 2002
Posts: 115
Or to put it another way, is this class shouting into Echo canyon, or just trying to look busy while doing nothing

SCJP 1.4
Jessica Sant

Joined: Oct 17, 2001
Posts: 4313

it prints just what you expect...
Guess what this is hello
Check out the API for String.toString()
"This object (which is already a string!) is itself returned."
Do you expect something else to happen??
Dominic Choo

Joined: Jan 30, 2003
Posts: 26
The result is:
Guess what this is hello
Not printing the hello for three times.
Jasper Vader
Ranch Hand

Joined: Jan 10, 2003
Posts: 284

this would probably give you a cool echo-chamber result, used to great effect by Led Zepelin in the seventies.

giddee up
I agree. Here's the link:
subject: Guess what this prints...
It's not a secret anymore!