1Z0-811 Arrays and Methods Practice Question
A developer implements a method to check if a number exists in an array using binary search. The array is not sorted. What will happen?
⚠ Common exam trap
A common mix-up: candidates assume binary search will still work or throw an error, but the exam tests the prerequisite that the array must be sorted for binary search to produce correct results.
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
✓
The method returns incorrect results sometimes.
Binary search requires the array to be sorted to work correctly. If the array is not sorted, the algorithm may skip over the target element or incorrectly conclude it is absent, leading to incorrect results. Therefore, the method returns incorrect results sometimes.
Answer analysis
Option-by-option breakdown
For each option: why learners choose it and why it is or isn't the right answer here.
- ✗
The method returns correct results always.
Why it's wrong here
Binary search assumes sorted order; it will not reliably find the element in an unsorted array.
- ✗
Runtime exception.
Why it's wrong here
No runtime exception is guaranteed; binary search runs without exception on unsorted arrays but gives wrong results.
- ✗
Compilation error.
Why it's wrong here
The code compiles fine; the logic is flawed but syntactically correct.
- ✓
The method returns incorrect results sometimes.
Why this is correct
Binary search may return incorrect results, such as not finding an existing element or returning a wrong index, because the array is not sorted.
Go deeper
Related to this question
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 →
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.