DifferenceModerate2 marks
Write a difference between the functions isUpperCase() and toUpperCase().
Topic: isUpperCase() and toUpperCase()
Previous-year question practice database
Answer
Exam answer
The difference is shown in the table.
Explanation
Two contrasts must appear: what each does, and what each RETURNS. The return type is the half candidates usually forget. Examples make it concrete: Character.isUpperCase('a') gives false, while Character.toUpperCase('a') gives 'A'. Note the naming pattern that runs through the Character class — every is... method returns boolean, every to... method performs a conversion.
Comparison
| isUpperCase() | toUpperCase() |
|---|---|
| Checks whether the given character is already in uppercase; it changes nothing. | Converts the given character to uppercase and returns the converted value. |
| Returns boolean — true or false. | Returns char (or String, for the String version). |
More from Library Classes
What is the output of the statement Math.pow(36, 6/5);?2026The output of the statement:
System.out.println(Character.toUpperCase('b') + 2); is:2026What is the type of parameter to be given for the method parseInt()?2026Write the Java expression to find the sum of cube root of x and the absolute value of y.2026Character class methods are found in the package called:2025The output of Math.max(-7, Math.min(-5, -4)) is2025