Courseiva
Primitives, Strings and OperatorshardMultiple ChoiceObjective-mapped

1Z0-811 Primitives, Strings and Operators Practice Question

What is the result of the following code? int a = 8; int b = 3; System.out.println(a >> 1);

⚠ Common exam trap

Oracle often tests the confusion between the right shift (`>>`) and left shift (`<<`) operators, as well as the misconception that `>> 1` always divides by 2 (which is true for positive integers but not for negative ones due to sign extension).

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

4

The right shift operator `>>` shifts the bits of the integer `a` (which is 8, binary `1000`) to the right by 1 position. This discards the least significant bit and fills the most significant bit with the sign bit (0 for positive numbers), resulting in binary `0100`, which is decimal 4. Therefore, `System.out.println(a >> 1)` prints 4.

Answer analysis

Option-by-option breakdown

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

  • 2

    Why it's wrong here

    Incorrect.

  • 3

    Why it's wrong here

    Incorrect.

  • 4

    Why this is correct

    8 shifted right by 1 is 4.

  • 16

    Why it's wrong here

    That would be left shift.

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.