• Post Reply Bookmark Topic Watch Topic
  • New Topic

output of the code  RSS feed

 
mohan hmpg
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ,
please write the remaining code of the program.


this is valid line in java

a.b=b.a


Regards,
mohan.
 
Hari haran Ravi
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
mohan hmpg wrote:hi ,
please write the remaining code of the program.


this is valid line in java

a.b=b.a


Regards,
mohan.


Hi Mohan, What are you trying to ask. I can't understand. Can you please give me more details
 
mohan hmpg
Greenhorn
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi ,
please write the remaining code of the program.


this is valid line in java

a.b=b.a


Regards,
mohan.

Thans for the immedate response.

actually this query was asked to me in an interview.

he has given just single line a.b=b.a and said that this is valid line in java.

write remaining part of the program.
 
Hari haran Ravi
Greenhorn
Posts: 26
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Ok then. I assume that the given statement a.b=b.a is correct.

It means that 'a' should be an object of a class that has 'b' as an instance variable.

similarly in the right hand side also, where 'b' is an object, and 'a' is an instance variable.

So the code might be,


I hope this is correct. Please do not blame me if it is wrong
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would have just added the missing semicolon and asked him what kind of stupid question is that--without any context anything is just a completely wild guess.
 
Jesper de Jong
Java Cowboy
Sheriff
Posts: 16060
88
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
David Newton wrote:I would have just added the missing semicolon and asked him what kind of stupid question is that--without any context anything is just a completely wild guess.

This is an interview question. There's not one single answer that is correct; there might be multiple possible correct answers. The intention of such a question is just to see how creative you are, and if you understand how Java works. The goal is not to write a program that does anything in particular that's useful.
 
David Newton
Author
Rancher
Posts: 12617
IntelliJ IDE Ruby
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If the goal is to find out really basic Java knowledge and how the interviewee reacts then provide a small task (FizzBuzz, or whatever), and leave it at that. Completely nebulous questions do everyone a disservice.
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!