Courseiva
Primitives, Strings and OperatorsmediumMultiple SelectObjective-mapped

1Z0-811 Primitives, Strings and Operators Practice Question

Which three of the following code snippets produce the output '5'?

⚠ Common exam trap

The trap here is that candidates often forget that `+` with a `String` operand triggers concatenation, not arithmetic, leading them to incorrectly select options A or D as producing `5`.

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

System.out.println(2 + 3);

The expression `2 + 3` performs integer addition, resulting in `5`, which is then passed to `System.out.println` and printed as the string representation of the integer `5`. Option C is correct because the string literal `"5"` is printed directly. Option E is correct because the integer literal `5` is printed as its string representation.

Answer analysis

Option-by-option breakdown

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

  • System.out.println(2 + "3");

    Why it's wrong here

    Concatenation gives "23".

  • System.out.println(2 + 3);

    Why this is correct

    Prints 5 as int.

  • System.out.println("5");

    Why this is correct

    Prints the string "5".

  • System.out.println("2" + 3);

    Why it's wrong here

    Concatenation gives "23".

  • System.out.println(5);

    Why this is correct

    Prints 5 as string.

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.