Granny's Programming Pearls
"inside of every large program is a small program struggling to get out"
JavaRanch.com/granny.jsp
The moose likes Beginning Java and the fly likes what is the output of this? Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login


Win a copy of Murach's Java Servlets and JSP this week in the Servlets forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "what is the output of this?" Watch "what is the output of this?" New topic
Author

what is the output of this?

harshitha Venkat
Greenhorn

Joined: Sep 28, 2012
Posts: 8
Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1107

when you run it what does it say?
and here is an article all about your real question (string pools)

all about strings

and incase that wasn't what you were getting at:

avoid the equality operator
Jelle Klap
Bartender

Joined: Mar 10, 2008
Posts: 1753
    
    7

The output when you feed this to the javac compiler would be: "Say what?!". Well actually it would be a whole bunch of errors.
If you fix those, though, the output of running this application would be...nah I don't want to spoil the surprise
Why don't you give fixing the syntax errors a try, and running the program?
If you then find yourself confused about the output you should read this.

Edit: Beaten by 22 seconds...

Build a man a fire, and he'll be warm for a day. Set a man on fire, and he'll be warm for the rest of his life.
harshitha Venkat
Greenhorn

Joined: Sep 28, 2012
Posts: 8
Jelle Klap wrote:The output when you feed this to the javac compiler would be: "Say what?!". Well actually it would be a whole bunch of errors.
If you fix those, though, the output of running this application would be...nah I don't want to spoil the surprise
Why don't you give fixing the syntax errors a try, and running the program?
If you then find yourself confused about the output you should read this.

Edit: Beaten by 22 seconds...

thank you so much for your reply this question was my interview question to which i was completely blank I really do not know the strings as am very new to this technology would thank you if you suggest me some good sites to learn java
harshitha Venkat
Greenhorn

Joined: Sep 28, 2012
Posts: 8
Wendy Gibbons wrote:when you run it what does it say?
and here is an article all about your real question (string pools)

all about strings

and incase that wasn't what you were getting at:

avoid the equality operator


Hello thank you for the reply .This was my interview question
Saket Kumar Sinha
Ranch Hand

Joined: Aug 04, 2011
Posts: 31


A copy of TATA MC Graw Hill Sun Certified Java Certification 6 Book will make you learn all the concepts thoroughly .
Wendy Gibbons
Bartender

Joined: Oct 21, 2008
Posts: 1107

Saket Kumar Sinha wrote:
A copy of TATA MC Graw Hill Sun Certified Java Certification 6 Book will make you learn all the concepts thoroughly .


but honestly who really needs to know if 2 string objects are equal? and interviews that ask you, avoid those jobs.
Jeff Verdegan
Bartender

Joined: Jan 03, 2004
Posts: 6109
    
    6

Saket Kumar Sinha wrote:
A copy of TATA MC Graw Hill Sun Certified Java Certification 6 Book will make you learn all the concepts thoroughly .


Dependign on how you use it, it might help you to understand Java better. However, I would guess that the way it's written and the way most people probably use it is to be able to pass the cert exam, which has very little to do with actually understanding Java.
Mike Simmons
Ranch Hand

Joined: Mar 05, 2008
Posts: 2982
    
    9
Wendy Gibbons wrote:but honestly who really needs to know if 2 string objects are equal? and interviews that ask you, avoid those jobs.

Well, I doubt they really need to know if two strings are equal. They are trying to find out if the candidate knows some Java fundamentals -- in in this case, the difference between equals() and ==. And if the candidate is in fact new to Java, it's not such an unreasonable question to ask. Presumably they've got a role that a Java beginner might be able to fill, but they want to assess how much of a beginner.
Campbell Ritchie
Sheriff

Joined: Oct 13, 2005
Posts: 37923
    
  22
It may be a very simple starting question. A bit like the exercise about write a fizz‑buzz program. If you can’t answer something that simple, they know you ain’t going to get far with more difficult questions.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: what is the output of this?
 
Similar Threads
Generics question
Initialization question
Sorting the String Saved in ArrayList
convert ArrayList of String[] to String[][]
testing a delimeter