Win a copy of Functional Reactive Programming this week in the Other Languages forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

System.out.println() question

 
Karn Kumar
Ranch Hand
Posts: 153
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 5575
Eclipse IDE Java Windows XP
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
after returning main? if yes:look for threads else include one more out.print ;)
 
Karn Kumar
Ranch Hand
Posts: 153
Eclipse IDE Java Tomcat Server
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Pie
Posts: 50273
80
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 187
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 187
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Try out...
 
Campbell Ritchie
Sheriff
Pie
Posts: 50273
80
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Gaurangkumar Khalasi wrote:Try out...
That should work, yes.
 
Michael Krimgen
Ranch Hand
Posts: 35
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
just another idea. Here you can modify the initial output however you like:



Cheers,
Michael
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic