Java OCA OCP Practice Question 836

Question

Which of these expressions will return true?

Select 4 options

A.  "hello world".equals ("hello world") 
B.  "HELLO world".equalsIgnoreCase ("hello world") 
C.  "hello".concat (" world").trim ().equals ("hello world") 
D.  "hello world".compareTo ("Hello world") < 0 
E.  "Hello world".toLowerCase ( ).equals ("hello world") 


Correct Options are  : A B C E

Note

For Option B.

equalsIgnoreCase() method treats both cases (upper and lower) as same.

For Option C.

"hello".concat(" world") will return "hello world" and trim() won't do any change because there is no space at the beginning or end of the string.

For Option D.

Notice that the Strings differ at the first position.

For Option E.

toLowerCase() converts all uppercase letters to lower case. Explanation:




PreviousNext

Related