Java OCA OCP Practice Question 2012

Question

Which expression will evaluate to true?.

Select the one correct answer.

(a)  "hello: there!".equals("hello there")
(b)  "HELLO THERE".equals("hello there")
(c)  ("hello".concat("there")).equals("hello there")
(d)  "Hello There".compareTo("hello there") == 0
(e)  "Hello there".toLowerCase().equals("hello there")


(e)

Note

The expression "Hello there".toLowerCase().equals("hello there") will evaluate to true.

The equals() method in the String class will only return true if the two strings have the same sequence of characters.




PreviousNext

Related