1. Home
  2. Computer Science MCQs
  3. JAVA
  4. In Java, what does "Hello" == new String("Hello") evaluate…

Added 2 Nov 2026

In Java, what does "Hello" == new String("Hello") evaluate to?

  1. false Correct answer
  2. true
  3. A runtime exception
  4. A compile-time error

Correct answer

A. false

14 views

MCQSEXAM

Explanation

== compares references, not content. new String always creates a separate object outside the string pool, so the result is false. Use .equals() to compare text.

Reference

Asked in: NTS, OCA Java, Technical Interviews

Preparing for an exam?

Doubts & discussion

Not sure why the answer is A? Ask here and get an explanation.

Ask a doubt about this MCQ

Shown after review. No links please.

More JAVA MCQs

Practise all JAVA MCQs

Similar MCQs