Courseiva
Primitives, Strings and OperatorsmediumMultiple ChoiceObjective-mapped

1Z0-811 Primitives, Strings and Operators Practice Question

Given: String s1 = "Java"; String s2 = new String("Java"); What does (s1 == s2) evaluate to?

Answer choices

Why each option matters

Answer the question above first, then reveal the full breakdown to understand why each option is right or wrong.

Correct answer & explanation

false

S1 is a string literal which is interned, while s2 is created using the 'new' keyword, resulting in a different object in heap memory. The '==' operator compares object references, so it returns false. Option A is incorrect because 'true if interned' is misleading; s1 is interned, but the comparison is false because s2 is a separate object. Option C ('true') is wrong because references differ. Option D ('Compilation error') is incorrect; the code compiles and runs without error.

Answer analysis

Option-by-option breakdown

For each option: why learners choose it and why it is or isn't the right answer here.

  • true if interned, false otherwise

    Why it's wrong here

    s1 is interned, s2 is not, so false.

  • false

    Why this is correct

    Different objects, == checks references.

  • true

    Why it's wrong here

    References are different.

  • Compilation error

    Why it's wrong here

    Valid code.

About these practice questions

This 1Z0-811 question is part of Courseiva's 481-question bank — original exam-style content with full explanations and wrong-answer analysis, never real exam questions or exam dumps. Learn why practice questions differ from exam dumps →

How Courseiva writes practice questions · Editorial policy

JA

Written by Johnson Ajibi, MSc IT Security

Senior Network & Security Engineer · founder of Courseiva

This 1Z0-811 practice question is part of Courseiva's free Oracle certification practice question bank. Courseiva provides original exam-style practice questions with explanations, topic-based practice, mock exams, readiness tracking, and study analytics to help learners prepare for the 1Z0-811 exam.