| Author |
System.out.println() question
|
Chetan Dorle
Ranch Hand
Joined: Aug 06, 2009
Posts: 128
|
|
Hi All,
One of the interviewer asked the below question
In main method we have out.println("world") stmt . After executing this we want output as Hello world . How will you write code without calling any method of other class or not passing runtime input from args[].
Can you guys please give your input.
Thanks in advance....
- Chetan
|
 |
Seetharaman Venkatasamy
Ranch Hand
Joined: Jan 28, 2008
Posts: 5575
|
|
|
after returning main? if yes:look for threads else include one more out.print ;)
|
 |
Chetan Dorle
Ranch Hand
Joined: Aug 06, 2009
Posts: 128
|
|
Hi Seetharaman ,
Thanks for the reply . Yes it is in the main() so will return output in the excution .
Can you please give some input on how to do it with threads.
Thanks ..
-Chetan
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32708
|
|
|
It says after executing this. Did you ask exactly what they mean by that? Simply leaping in with a solution is far less likely to get you appointed than asking lots of questions.
|
 |
Gaurangkumar Khalasi
Ranch Hand
Joined: Jun 02, 2012
Posts: 186
|
|
Chetan Dorle wrote:In main method we have out.println("world") stmt . After executing this we want output as Hello world . How will you write code without calling any method of other class or not passing runtime input from args[].
|
 |
Gaurangkumar Khalasi
Ranch Hand
Joined: Jun 02, 2012
Posts: 186
|
|
|
Try out...
|
 |
Campbell Ritchie
Sheriff
Joined: Oct 13, 2005
Posts: 32708
|
|
Gaurangkumar Khalasi wrote:Try out...
That should work, yes.
|
 |
Michael Krimgen
Ranch Hand
Joined: Jul 08, 2012
Posts: 34
|
|
just another idea. Here you can modify the initial output however you like:
Cheers,
Michael
|
 |
 |
|
|
subject: System.out.println() question
|
|
|