Courseiva
Primitives, Strings and OperatorshardMultiple SelectObjective-mapped

1Z0-811 Primitives, Strings and Operators Practice Question

Which three of the following are valid ways to declare and initialize a variable of type int? (Choose three.)

⚠ Common exam trap

Oracle often tests the distinction between valid integer literal formats and invalid ones, such as using a digit 2 in a binary literal or assigning a floating-point literal without a cast, which candidates might overlook due to familiarity with other languages.

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

int b = 0xA;

`0xA` is a hexadecimal integer literal in Java, representing the decimal value 10. Java allows hexadecimal literals using the prefix `0x` or `0X`, and they are valid for initializing an `int` variable.

Answer analysis

Option-by-option breakdown

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

  • int b = 0xA;

    Why this is correct

    Correct: hexadecimal literal 0xA equals 10 decimal.

  • int e = 10.0;

    Why it's wrong here

    Incorrect: 10.0 is a double literal, and assigning to int requires a cast.

  • int d = 010;

    Why this is correct

    Correct: octal literal 010 equals 8 decimal.

  • int c = 0b2;

    Why it's wrong here

    Incorrect: binary literal can only contain 0 and 1; '2' is invalid.

  • int a = 10;

    Why this is correct

    Correct: decimal literal 10 is valid for int.

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.