Welcome to the CSC Q&A.
Get help and give help!
Write great code!
It is our choices... that show what we truly are, far more than our abilities.

Categories

+19 votes

True/False:
cityName == “Rock Island” will compare the characters stored in the String variable cityName with the characters in the String literal “Rock Island”.

asked in CSC211_Winter2018 by (8 points)

2 Answers

+15 votes
 
Best answer

False, Dr. Mueller covered this in class the other day. The == compares the location that the string is stored in memory so it would be comparing cityName to the new string "Rock Island" that is stored in two different locations of Java.

answered by (8 points)
selected by
+2

Thank you!

+11 votes

False because you can't put == for a string instead cityName.equals("Rock Island")

answered by (8 points)
...