Courseiva
Java Basics and SyntaxeasyMultiple ChoiceObjective-mapped

1Z0-811 Java Basics and Syntax Practice Question

A developer writes: int x; System.out.println(x); What is the result?

⚠ Common exam trap

The Java Foundations exam often tests the distinction between local variables (which require explicit initialization) and instance/class variables (which receive default values), leading candidates to incorrectly assume that `int x` will default to 0.

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

Compilation fails

B is correct because in Java, a local variable (such as `int x;` declared inside a method) must be initialized before it is used. The code attempts to print `x` without assigning a value, which violates the definite assignment rule and causes a compilation 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.

  • null

    Why it's wrong here

    Incorrect. null is for reference types.

  • Compilation fails

    Why this is correct

    Correct. The variable x is not initialized.

  • Runtime error

    Why it's wrong here

    Incorrect. The error is at compile time.

  • 0

    Why it's wrong here

    Incorrect. Local variables do not get default values.

About these practice questions

One of 481 original 1Z0-811 practice questions on Courseiva, each with a full explanation and wrong-answer analysis — not exam dumps or protected exam content. 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.