Mastering Java: The Ultimate Quiz for 'Thinking in Java'

Disable ads (and more) with a membership for a one time $2.99 payment

Mastering Java: The Ultimate Quiz for 'Thinking in Java'. Dive deep into Java with multiple-choice questions. Challenge yourself with quiz questions designed to test and improve your understanding of the 'Thinking in Java' book. Get ready for your exam!

Practice this question and more.


What method produces a new String object with all letters changed to lowercase?

  1. tolowerCase()

  2. toLowerCase()

  3. lower()

  4. convertToLower()

The correct answer is: toLowerCase()

The method toLowerCase() is the only built-in method in Java that changes all letters in a String to lowercase. Option A, tolowerCase(), is incorrect because it includes a typo and is not a valid method name. Option C, lower(), is incorrect because it is not a built-in method in Java. Option D, convertToLower(), is incorrect because it is not a valid method name in Java and there is no built-in method with this name. Therefore, the correct answer is B, toLowerCase().