QuestionQ190

Using Operators and Decision Constructs

Given the following code fragment:

Question Image

Which code fragment, inserted at line n1, allows the App class to print Equal?

Question Image

  • A Option A
  • B Option B
  • C Option C
  • D Option D
Explanation

String objects are immutable, so toLowerCase() returns a new string rather than changing str1. str2.equals(str1.toLowerCase()) compares the contents of "java" and "java", so it evaluates to true.

Community Discussion

No comments yet. Be the first to start the discussion!