if("String".replace('t','T') == "String".replace('t','T')) System.out.println("Equal"); else System.out.println("Not Equal");

  1. will Print Equal

  2. will Print Not Equal

  3. compile time error

  4. none of the above


Correct Option: B

AI Explanation

To answer this question, let's go through each option to understand why it is correct or incorrect:

Option A) will Print Equal - This option is incorrect because the statement in the if condition will evaluate to false, resulting in the "Not Equal" message being printed.

Option B) will Print Not Equal - This option is correct. The statement in the if condition will evaluate to false because the two expressions on either side of the equality operator are not equal.

Option C) compile time error - This option is incorrect. There is no compilation error in the given code.

Option D) none of the above - This option is incorrect. The correct answer is Option B.

The correct answer is B. The code will print "Not Equal" because the two expressions "String".replace('t','T') and "String".replace('t','T') are not equal.

Find more quizzes: