Exam Information
Free practice questions with explanations
Oracle 1Z0-811 Practice Questions
Answer a question to see the correct answer and the explanation, or click Show answer. Newest questions first.
- Questions
- 12
- Answered
- 0
- Correct
- 0
- Score
- -
-
1 Question 1 Single choice Arrays and ArrayLists
A payroll service stores the hourly rates of 500 contractors in a fixed-length int array. Later, the business needs to append rates as new contractors are onboarded during the day, and it must avoid writing its own resizing logic. A developer proposes switching to a java.util.ArrayList and iterating over it with an enhanced for loop. The team also has a memory budget that forbids boxing overhead for the bulk of the data loaded at startup. Which approach best meets all requirements?
Correct Answer: CExplanationA plain array stores int values directly with no boxing, which satisfies the memory constraint for the bulk startup data, while an ArrayList grows automatically and avoids hand-written resizing for the daily additions. Manual copying defeats the goal of avoiding resizing logic. ArrayList is illegal because generics accept only reference types, and the choice that puts everything in an ArrayList ignores the boxing overhead the budget forbids.
-
2 Question 2 Multiple choice Basic Java Elements
A team reviews a legacy source file that must be cleaned up before it is handed to a code-quality pipeline. The file uses a utility class from java.util and the java.lang.Math class, and the reviewers want the code to follow Java naming conventions and syntax rules. Which TWO statements about the file are correct? (Choose two.)
Correct Answer: C, EExplanationThe compiler automatically imports java.lang, so Math.max needs no import. Classes outside java.lang, such as java.util.Scanner, must be imported or referenced by their fully qualified name. Lowercase class names compile but break conventions, which makes option A a convention issue rather than a valid answer. record is a contextual keyword, not a reserved word, so it may be used as an identifier in many contexts. Multi-line comments do not nest, so an inner close delimiter ends the comment early and causes a compile error.
-
3 Question 3 Order list Classes and Constructors
A developer must create a Vehicle class for a fleet system. The class needs a private odometer field, a constructor that accepts a model name, and a no-argument constructor that delegates to the first one. A main method must then create an object and update its state through a public method. Arrange the steps in the order they must be performed.
Drag the steps into the correct order, or use the arrows.
- Add a public mutator method that updates odometer, then create a Vehicle object in main and call it
- Declare the class Vehicle with a private String model field and a private int odometer field
- Write a constructor that takes a String parameter and assigns it to the model field
- Write a no-argument constructor that calls this with a default model name
Correct Answer:- Declare the class Vehicle with a private String model field and a private int odometer field
- Write a constructor that takes a String parameter and assigns it to the model field
- Write a no-argument constructor that calls this with a default model name
- Add a public mutator method that updates odometer, then create a Vehicle object in main and call it
ExplanationThe class and its fields must exist before any constructor can assign them, so the declaration comes first. The parameterised constructor is written before the no-argument constructor, because the latter uses this(...) to delegate to it, and a constructor call through this must appear as the first statement. The mutator and the main method that exercises the object come last, since main depends on the completed class. Writing main first would not compile against an empty class.
-
4 Question 4 Single choice Debugging and Exception Handling
A batch job reads account numbers from a text file and converts each line with Integer.parseInt before posting it to a ledger. Most lines are valid, but occasional blank lines and corrupted entries cause the whole job to terminate with an uncaught exception, halting settlement for hours. The business requires that bad lines be skipped and logged while processing continues for the rest of the file. Which change is the most appropriate fix?
Correct Answer: BExplanationPlacing the try block around the parseInt call and catching NumberFormatException keeps the loop running, so bad lines are logged and skipped while good lines still post. Wrapping the whole loop stops processing at the first failure, which violates the requirement to continue. Rethrowing after logging still halts the job. Removing handling ignores the stated corruption, and the claim of upstream validation is not something the stem supports.
-
5 Question 5 Dropdown Java Basics
A junior engineer on a build team is preparing a deployment host to run a prebuilt application and to compile new source code with the same toolchain. The host must be able to run the compiled program and also run javac. Complete the statements by selecting the correct value for each blank.
Choose the correct value for each blank.
To compile Main.java on the host, the engineer must install the , which contains the javac compiler. To run the compiled Main class, the host needs the at minimum.Correct Answer:To compile Main.java on the host, the engineer must install the JDK, which contains the javac compiler. To run the compiled Main class, the host needs the JRE at minimum.
ExplanationThe JDK bundles the development tools such as javac together with a runtime, so it is required for compiling source files. The JRE provides the runtime libraries and the JVM needed to execute bytecode, which is all a host that only runs programs needs. javac is a tool, not an installable runtime package, and the Java Card API targets smart cards rather than general compilation.
-
6 Question 6 Single choice Java Methods
A retail analytics library exposes a static utility method computeDiscount(double price, double rate). A colleague wants to add a second method with the same name so that callers can omit the rate and receive a default 10 percent discount. The library is compiled against a binary dependency, and the team has a strict rule that existing callers must not need recompilation. Which implementation satisfies the requirements?
Correct Answer: DExplanationOverloading by parameter count adds computeDiscount(double) without altering the existing signature, so compiled callers keep working. Renaming breaks every existing binary caller that references the original name. An overload with int rate is distinct but does not provide the default-omission behaviour the colleague needs, and altering the return type or signature of the original method would break binary compatibility. Java has no default-argument syntax, so option D is not possible.
-
7 Question 7 Multiple choice Using Decision Statements
A loan approval module compares customer identifiers and loan product codes. The reviewers notice inconsistent results: two identical product codes sometimes fail a check, and a branching statement on a customer tier code behaves unexpectedly when the tier is read from a String. Which TWO corrections make the comparisons reliable? (Choose two.)
Correct Answer: B, CExplanationThe == operator on String references compares identity, so content equality must use equals, which the first correction provides. A switch on a String compares values with equals semantics, making it a valid reliable branch. compareTo returns zero for equal strings but its purpose is ordering, and comparing Integer objects with == is unreliable outside the cached range, so B and D are wrong. Since Java 7, switch supports String, so E is incorrect.
-
8 Question 8 Drag and drop Using Looping Statements
A data quality team is designing loops for three processing tasks. Task one must process a list of invoices at least once even when the list is empty, task two iterates over an array without needing an index, and task three is a retry loop whose number of iterations is not known in advance but must test the condition before every attempt. Match each task to the loop construct that best fits it.
Drag each item onto its matching target. On a phone: tap an item, then tap a target.
Process at least one invoice even if the batch is emptyRetry until the connection succeeds, testing the condition before each attemptRead every element of an array without using an indexdo-while loopwhile loopenhanced for loopswitch statementCorrect Answer:- Retry until the connection succeeds, testing the condition before each attempt → while loop
- Process at least one invoice even if the batch is empty → do-while loop
- Read every element of an array without using an index → enhanced for loop
ExplanationA while loop checks its condition before each iteration, which suits a retry whose count is unknown beforehand. A do-while loop executes its body once before testing, so it guarantees a single pass over an empty batch. The enhanced for loop iterates over array elements directly without exposing an index. A switch statement selects among cases and does not provide any repetition.
-
9 Question 9 Single choice Working with Java Data Types
A telemetry module receives sensor readings as long values and must store them in an int field for a legacy interface. An engineer writes int reading = longValue; and the build fails. The team needs the code to compile while making sure values outside the int range are not silently wrapped to incorrect numbers. Which change is the most appropriate?
Correct Answer: DExplanationMath.toIntExact performs a checked narrowing and throws ArithmeticException on overflow, so the code compiles and out-of-range readings are never wrapped silently. An explicit cast compiles but truncates bits, producing incorrect values without any error, which violates the requirement. Converting to float does not fix the int interface and loses precision. Declaring the variable final does not change the narrowing rule that forbids implicit conversion from long to int.
-
10 Question 10 Single choice Working with the String Class
A reporting service formats a summary line for each customer using String.format. The template must output a customer name followed by an integer order count and then a line break, and the team wants to avoid platform-specific newline characters in the template. Which format string produces the required output with the correct specifiers?
Correct Answer: CExplanationThe %s specifier formats the name, %d formats the integer count, and %n inserts the platform-appropriate line separator, which satisfies the portability requirement. Option B uses \n, which is a literal escape rather than the platform separator the team asked for, and it swaps the argument types. Option C reverses the count specifier onto the wrong argument. Option D uses %ln, which is not a valid format conversion and will throw an exception at runtime.
-
11 Question 11 Dropdown Working with the Random and Math Classes
A simulation tool must generate a random integer between 1 and 6 inclusive for a dice roll and must round a computed average down to the nearest whole number without using floating point rounding in the output. The developer is completing the expressions below. Select the correct value for each blank.
Choose the correct value for each blank.
int roll = + random.nextInt(6); and int floored = (int) Math.(averageValue);Correct Answer:int roll = 1 + random.nextInt(6); and int floored = (int) Math.floor(averageValue);
ExplanationnextInt(6) returns values from 0 through 5, so adding 1 shifts the range to 1 through 6 inclusive. Math.floor returns the largest whole number not greater than the argument, which is the required downward rounding. Math.round rounds to nearest rather than down, and Math.ceil rounds upward, so both fail the requirement. Math.rint rounds to the nearest even value on ties and does not guarantee downward rounding.
-
12 Question 12 Single choice Java Basics
A company is evaluating whether its internal order service should be written in Java. The engineering manager wants the team to use features that help the codebase remain portable across Linux and Windows servers without recompiling the source for each operating system, and that let developers run the same bytecode on either platform. Which property of Java best satisfies this requirement?
Correct Answer: CExplanationJava source compiles to platform-neutral bytecode, which the JVM on each operating system executes, so the same class files run on Linux and Windows. Native compilation would require a separate build per platform, contradicting the requirement. Garbage collection manages memory but does not provide portability of compiled code. A GUI toolkit concerns interface design and is not the mechanism that makes the program portable across servers.
These are 12 of the 75 questions in the full 1Z0-811 pack.
Get All 75 QuestionsGet all 75 questions & answers
Full access options for Oracle 1Z0-811
Self-study
PDF Version
- 75 actual exam questions
- Compatible with all devices
- Printable PDF format
- No download limits
- 90 days free updates
- 24/7 customer support
Best value
Bundle Pack
- Discounted PDF + online access
- 75 actual exam questions
- Both PDF and online practice test
- Free 90 days updates
- No download or practice limits
- 24/7 customer support
Exam simulation
Online Practice Test
- 75 actual exam questions
- Actual exam environment
- 90 days free updates
- Browser-based software
- 24/7 customer support
100% Money Back Guarantee
Your success comes first
At DumpsProvider, we give you a 100% money back guarantee on all of our exam dumps. For us, your success is the #1 priority and we are more than confident that our exam material will help you pass the 1Z0-811 Exam (Java Foundations) on your very first attempt.
In a rare case, if you fail your exam, we will refund your amount without asking a single question.