Single Choice Easy

QAssertion(A): The String class in Java is immutable.
Reason(R): Immutable object can not be modified once they are created and any operation on a String object results in the creating of a new String object.

ID: #22234 switch case in Java 103 views
Question Info
#22234Q ID
EasyDifficulty
switch case in JavaTopic

Choose the Best Option

Click any option to instantly check if you're correct.

  • A Both Assertion(A) and Reason(R) are true and Reason(R) is correct explanation of Assertion(A).
  • B Both Assertion(A) and Reason(R) are true and Reason(R) is not correct explanation of Assertion(A).
  • C Assertion(A) is true and Reason(R) is false.
  • D Assertion(A) is false and Reason(R) is true.
Correct Answer

Explanation

  • Assertion (A): The String class in Java is immutable.

    • True. In Java, once a String object is created, it cannot be changed. Any modification to a String object results in the creation of a new String object.
  • Reason (R): Immutable objects cannot be modified once they are created, and any operation on a String object results in the creation of a new String object.

    • True. This is a correct explanation of immutability. Since String objects are immutable, any operation that appears to modify a String actually creates a new String object.

Correct Answer:

a) Both Assertion(A) and Reason(R) are true and Reason(R) is correct explanation of Assertion(A).

Share This Question

Challenge a friend or share with your study group.