Courseiva
Knowledge + Practice
CertificationsVendorsCareer RoadmapsLabs & ToolsStudy GuidesGlossaryPractice Questions
C
Courseiva

Free IT certification practice questions with explained answers for CCNA, CompTIA, AWS, Azure, Google Cloud, and more.

Certification Practice Questions

CCNA practice questionsSecurity+ SY0-701 practice questionsAWS SAA-C03 practice questionsAZ-104 practice questionsAZ-900 practice questionsCLF-C02 practice questionsA+ Core 1 practice questionsGoogle Cloud ACE practice questionsCySA+ CS0-003 practice questionsNetwork+ N10-009 practice questions
View all certifications →

Product

CertificationsCertification PathsExam TopicsPractice TestsExam Dumps vs Practice TestsStudy HubComparisons

Company

AboutContactEditorial PolicyQuestion Writing PolicyTrust Center

Legal

Privacy PolicyTerms of Service

Courseiva is a free IT certification practice platform offering original exam-style practice questions, detailed explanations, topic-based practice, mock exams, readiness tracking, and study analytics for Cisco, CompTIA, Microsoft, AWS, and other technology certifications.

© 2026 Courseiva. Courseiva is operated by JTNetSolutions Ltd. All rights reserved.

Courseiva is an independent certification practice platform and is not affiliated with, endorsed by, or sponsored by Cisco, Microsoft, AWS, CompTIA, Google, ISC2, ISACA, or any other certification vendor. Vendor names and certification marks are used only to identify the exams learners are preparing for.

HomeCertifications1Z0-811Exam Questions

Oracle · Free Practice Questions · Last reviewed May 2026

1Z0-811 Exam Questions and Answers

42real exam-style questions organised by domain, each with the correct answer highlighted and a plain-English explanation of why it's right — and why the others are wrong.

75 exam questions
75 min time limit
Pass: 650/1000 / 1000
7 exam domains
OverviewDomain BlueprintStudy GuideAll QuestionsSample by Domain
1. What is Java2. Java Basics and Syntax3. Primitives, Strings and Operators4. Control Flow and Loops5. Arrays and Methods6. Object-Oriented Programming7. Exception Handling and Development Tools
1

Domain 1: What is Java

All What is Java questions
Q1
mediumFull explanation →

A developer is writing a Java application that processes a large number of transactions. The application must ensure that each transaction is committed only if all steps complete successfully, otherwise the entire transaction should be rolled back. Which Java concept should the developer use to implement this requirement?

A

Exception handling

Exception handling can catch failures and trigger rollback.

B

Inheritance

C

Multithreading

D

Encapsulation

Why: Option A is correct because exception handling in Java allows the developer to catch runtime failures (e.g., SQLException, IOException) within a try block and, in the catch block, invoke a rollback on the transaction (e.g., Connection.rollback()). If all steps succeed, the transaction is committed via Connection.commit(). This ensures atomicity — the 'all-or-nothing' property required for transaction processing.
Q2
easyFull explanation →

A team is designing a Java application that needs to run on different operating systems without modification. Which Java feature makes this possible?

A

The Java Virtual Machine

JVM interprets bytecode on any platform, providing portability.

B

Just-in-time compilation

C

Garbage collection

D

The Java compiler

Why: The Java Virtual Machine (JVM) is the key enabler of Java's 'write once, run anywhere' capability. When you compile Java source code, the Java compiler produces bytecode, which is platform-independent. This bytecode is then executed by the JVM, which is implemented specifically for each operating system (Windows, Linux, macOS, etc.), translating the bytecode into native machine instructions. Therefore, the same compiled .class file can run on any OS that has a compatible JVM, without requiring any modifications to the application code.
Q3
hardFull explanation →

Which TWO statements correctly describe the Java language? (Choose two.)

A

Java supports multiple inheritance of implementation.

B

Java supports operator overloading.

C

Java supports object-oriented programming.

Java is primarily object-oriented.

D

Java supports multiple inheritance of classes.

E

Java is a statically typed language.

Variables must be declared with a type before use.

Why: Option C is correct because Java is fundamentally an object-oriented programming language that supports encapsulation, inheritance, and polymorphism. Java's design revolves around classes and objects, and all code must be written inside a class, making OOP a core principle of the language.
Q4
mediumFull explanation →

A developer runs the command shown in the exhibit. The developer wants to ensure the application uses the latest available language features. Which action should the developer take?

A

Download and install a newer version of the JDK.

A newer JDK includes both compiler and runtime with latest features.

B

Enable lambda expressions by setting the -enable-lambdas flag.

C

Use the -source and -target flags to compile for a newer version.

D

Upgrade the JVM to the latest version.

Why: Option A is correct because the latest available language features (e.g., pattern matching, sealed classes, records) are tied to the JDK version. Downloading and installing a newer JDK provides both the compiler (javac) and runtime (JVM) that support those features. Simply upgrading the JVM (Option D) or using -source/-target flags (Option C) does not enable new language syntax in the compiler if the JDK itself is outdated.
Q5
hardFull explanation →

A company is developing a Java-based inventory management system. The system runs on a single server and processes up to 1000 concurrent requests. The development team has implemented the code using multiple threads to handle requests. Recently, the system has been experiencing intermittent data corruption in the inventory counts. After reviewing the code, the team suspects that the issue is related to thread safety. The team is considering the following solutions: (A) Use the 'synchronized' keyword on all methods that update inventory counts. (B) Use 'volatile' keyword on the inventory count variables. (C) Use 'AtomicInteger' for inventory counts. (D) Increase the number of threads to handle requests faster. Which solution should the team implement to fix the data corruption issue with minimal performance impact?

A

Use 'AtomicInteger' for inventory counts.

AtomicInteger provides lock-free, thread-safe operations with good performance.

B

Increase the number of threads to handle requests faster.

C

Use 'volatile' keyword on the inventory count variables.

D

Use the 'synchronized' keyword on all methods that update inventory counts.

Why: Option A is correct because AtomicInteger provides thread-safe atomic operations (like incrementAndGet) without requiring synchronization, ensuring consistent inventory counts under concurrent access with minimal performance overhead compared to full method synchronization.
Q6
mediumFull explanation →

Arrange the steps to compile and run a Java program from the command line in the correct order.

Why: The correct order is to first write the code, then open terminal, navigate to the file location, compile with javac, and run with java.

Want more What is Java practice?

Practice this domain
2

Domain 2: Java Basics and Syntax

All Java Basics and Syntax questions
Q1
easyFull explanation →

A developer writes the following code: int x = 5; System.out.println(x++); What is the output?

A

Compilation error

B

5

x++ returns 5, then x becomes 6.

C

6

D

Runtime exception

Why: The expression `x++` is a post-increment operator, which returns the current value of `x` (5) before incrementing it. Therefore, `System.out.println(x++)` prints 5, and then `x` becomes 6. Option B is correct because the output is the original value of `x`.
Q2
mediumFull explanation →

A team decides to use a single Java source file for a small application. Which statement is true about the file structure?

A

It must have a main method to compile.

B

It can contain multiple public classes.

C

It can contain exactly one public class with the same name as the file.

This is the standard rule.

D

The public class name can differ from the file name.

Why: Option C is correct because in Java, when a source file contains a public class, the file name must exactly match the public class name, including case sensitivity. This is a fundamental rule enforced by the Java compiler to ensure proper class loading and package structure. The file can have at most one public top-level class, and that class name determines the file name.
Q3
hardFull explanation →

Given the code: String s1 = "Java"; String s2 = new String("Java"); if (s1 == s2) { System.out.print("Equal"); } else { System.out.print("Not Equal"); } What is the output?

A

Runtime error

B

Compilation error

C

Equal

D

Not Equal

s1 is interned, s2 is a new object.

Why: Option D is correct because the == operator compares object references, not the actual string content. s1 is a string literal stored in the string pool, while s2 is a new String object created on the heap, so they refer to different memory locations, making the comparison false and printing 'Not Equal'.
Q4
easyFull explanation →

Which primitive data type should be used to store a single character?

A

int

B

byte

C

char

char is a 16-bit Unicode character.

D

String

Why: Option C is correct because the `char` primitive data type in Java is specifically designed to store a single 16-bit Unicode character, ranging from '\u0000' (0) to '\uffff' (65,535). It can represent any character in the Unicode standard, including letters, digits, and symbols, making it the appropriate choice for a single character value.
Q5
mediumFull explanation →

A method is declared as: public static void main(String[] args) { }. Which statement is true?

A

The method can be overridden in a subclass.

B

The method can return an int.

C

The method can be called without creating an instance of the class.

It is static, so it belongs to the class.

D

The method can be private.

Why: Option C is correct because the `static` modifier in the method signature means the method belongs to the class itself, not to any instance. Therefore, it can be invoked using the class name (e.g., `ClassName.main(args)`) without creating an object of the class. This is a fundamental characteristic of static methods in Java.
Q6
hardFull explanation →

Which code snippet correctly creates a two-dimensional array with 3 rows and 4 columns?

A

int[][] array = new int[3,4];

B

int[] array[] = new int[3][4];

C

int array[][] = new int[3,4];

D

int[][] array = new int[3][4];

Correct syntax.

Why: Option D is correct because Java uses separate bracket pairs for each dimension when declaring and initializing a two-dimensional array. The syntax `int[][] array = new int[3][4];` correctly creates an array with 3 rows and 4 columns, where each element defaults to 0.

Want more Java Basics and Syntax practice?

Practice this domain
3

Domain 3: Primitives, Strings and Operators

All Primitives, Strings and Operators questions
Q1
easyFull explanation →

Given the code snippet: int x = 5; int y = 2; double result = x / y; What is the value of result?

A

2.0

Correct because integer division yields 2, then cast to double.

B

Compilation fails

C

2.5

D

2

Why: Option A is correct because in Java, when both operands of the division operator are integers (int), integer division is performed, which truncates the fractional part. Here, x / y evaluates to 5 / 2 = 2 (integer division), and then the int value 2 is implicitly widened to double 2.0 when assigned to the double variable result.
Q2
mediumFull explanation →

A developer writes: String s = "Hello"; s.concat(" World"); System.out.println(s); What is the output?

A

Compilation fails

B

Hello World

C

Hello

Correct because concat does not modify s.

D

Hello World

Why: Option C is correct because strings in Java are immutable. The `concat()` method returns a new string but does not modify the original string `s`. Since the return value is not assigned to any variable, the original string `s` remains unchanged, so `System.out.println(s)` prints "Hello".
Q3
hardFull explanation →

Given: String str = "Java"; str = str.concat(" SE"); str.replace('a', 'A'); System.out.println(str); What is the output?

A

Java

B

JAVA SE

C

Java SE

Correct because replace result is ignored.

D

JAvA SE

Why: Option C is correct because the `concat` method returns a new String "Java SE" which is assigned back to `str`. The `replace` method also returns a new String but its result is not assigned to any variable, so the original `str` remains unchanged. The final `println` outputs the current value of `str`, which is "Java SE".
Q4
mediumFull explanation →

Which operator is used to compare two strings for value equality in Java?

A

compareTo()

B

=

C

==

D

equals()

Correct for value equality.

Why: Option D is correct because the equals() method in Java's String class compares the actual character sequences of two strings for value equality. Unlike the == operator, which checks reference equality (whether two references point to the same object in memory), equals() performs a lexicographic comparison of the string contents, returning true if and only if both strings have the same length and the same characters in the same order.
Q5
easyFull explanation →

What is the result of: System.out.println(10 + 20 + "30");

A

102030

B

3030

Correct because addition then concatenation.

C

30

D

Compilation fails

Why: In Java, the '+' operator is left-associative. The expression `10 + 20 + "30"` is evaluated as `(10 + 20) + "30"`, which first performs integer addition to get `30`, then concatenates that integer with the string `"30"`, resulting in the string `"3030"`. The `System.out.println` method then prints the string `3030`.
Q6
hardFull explanation →

Given: boolean a = false; boolean b = true; boolean c = true; System.out.println(a || b && c); What is the output?

A

false

B

Compilation fails

C

None of the above

D

true

Correct due to operator precedence.

Why: In Java, the logical AND operator (&&) has higher precedence than the logical OR operator (||). Therefore, the expression `a || b && c` is evaluated as `a || (b && c)`. Given `a = false`, `b = true`, and `c = true`, `b && c` evaluates to `true`, and then `false || true` evaluates to `true`. Thus, the output is `true`, making option D correct.

Want more Primitives, Strings and Operators practice?

Practice this domain
4

Domain 4: Control Flow and Loops

All Control Flow and Loops questions
Q1
mediumFull explanation →

A developer writes a loop to iterate over an array of integers. The loop must sum all elements and stop early if the sum exceeds 100. Which control flow construct should be used?

A

while(true) { sum += arr[i]; i++; }

B

for(int i=0; i<arr.length; i++) { sum += arr[i]; if(sum > 100) break; }

Correctly uses for loop and break to exit early.

C

do { sum += arr[i]; i++; } while(i<arr.length && sum <= 100);

D

for(int val : arr) { sum += val; if(sum > 100) break; }

Why: Option B is correct because it uses a for loop with an index variable to iterate over the array, and includes an if statement with a break to exit the loop early when the sum exceeds 100. This ensures all elements are summed until the condition is met, and the loop stops immediately, preventing unnecessary iterations.
Q2
easyFull explanation →

Which loop is guaranteed to execute its body at least once?

A

repeat-until loop

B

while loop

C

do-while loop

Executes body then checks condition.

D

for loop

Why: The do-while loop is a post-test loop, meaning the condition is evaluated after the loop body executes. This guarantees that the body runs at least once, regardless of whether the condition is initially true or false. In Java, the do-while loop syntax is `do { ... } while (condition);`.
Q3
hardFull explanation →

A developer needs to implement a menu-driven program that repeatedly displays options, reads input, and processes the choice until the user selects 'Exit'. Which loop structure and control flow is most appropriate?

A

for loop with break condition and nested if-else

B

for(;;) loop with if-else chain

C

do-while loop with switch statement

Ensures menu displays once, switch is clear for multiple options.

D

while(true) loop with if-else chain

Why: Option C is correct because a do-while loop guarantees at least one iteration, which is ideal for menu-driven programs where the menu must be displayed before any input is processed. The switch statement provides a clean, readable way to handle multiple discrete choices (like menu options) compared to a chain of if-else statements, and it aligns with Java's control flow best practices for such scenarios.
Q4
mediumFull explanation →

What is the output of the following code?

int i = 0;
while (i < 5) {
    if (i == 3) {

i++; continue;

}

System.out.print(i + " "); i++;

}
A

0 1 2 4

Correctly skips 3 due to continue.

B

0 1 2 3

C

0 1 2 4 5

D

0 1 2 3 4

Why: The while loop iterates while i < 5. When i equals 3, the if condition triggers, incrementing i to 4 and then using continue to skip the print statement for that iteration. Thus, 3 is never printed, and the loop prints 0, 1, 2, and then 4 before i becomes 5 and the loop ends.
Q5
easyFull explanation →

Which statement about the for-each loop in Java is true?

A

It cannot remove elements from a collection during iteration without additional logic.

Correct: removal causes ConcurrentModificationException.

B

It can modify the array elements.

C

It can iterate in reverse order.

D

It cannot be used with arrays.

Why: Option A is correct because the for-each loop (enhanced for loop) in Java does not expose the iterator or index, so you cannot safely remove elements from a collection during iteration without using an explicit iterator and its remove() method. Attempting to remove directly will throw a ConcurrentModificationException.
Q6
hardFull explanation →

A developer writes: for(int i=0; i<10; i++) { if(i%2==0) continue; System.out.print(i); }. What is the output?

A

0123456789

B

13579

Correctly prints odd numbers.

C

02468

D

123456789

Why: The loop iterates from i=0 to i=9. The `continue` statement skips the rest of the loop body when the condition `i%2==0` is true (i.e., when i is even). Therefore, only odd values of i (1, 3, 5, 7, 9) are printed, producing the output '13579'. Option B is correct.

Want more Control Flow and Loops practice?

Practice this domain
5

Domain 5: Arrays and Methods

All Arrays and Methods questions
Q1
mediumFull explanation →

A developer writes a method that takes an int array and returns the sum of its elements. The method signature is: 'public static int sumArray(int[] arr)'. Which statement correctly calls this method?

A

int result = sumArray(new int[]{1,2,3});

Creates and passes an anonymous int array.

B

int result = sumArray(true);

C

int result = sumArray([1,2,3]);

D

int result = sumArray(5);

Why: Option A is correct because it uses the correct syntax for creating and passing an anonymous int array to the sumArray method. The expression `new int[]{1,2,3}` creates an int array object with the specified elements, which matches the method's parameter type `int[]`. The method then returns the sum, which is assigned to the int variable `result`.
Q2
easyFull explanation →

Given the code snippet: 'int[] nums = {10, 20, 30, 40}; int sum = 0; for (int i = 0; i < nums.length; i++) { sum += nums[i]; }'. What is the value of sum after execution?

A

100

Sums all four elements correctly.

B

30

C

60

D

140

Why: The correct answer is A (100) because the for loop iterates over each element of the array {10, 20, 30, 40} and adds it to the sum variable. The sum starts at 0, and after adding 10, 20, 30, and 40, the total becomes 100.
Q3
hardFull explanation →

A method 'public static void modifyArray(int[] arr) { arr[0] = 99; }' is called with 'int[] myArray = {1,2,3}; modifyArray(myArray); System.out.println(myArray[0]);'. What is the output?

A

99

The method modifies the array element.

B

1

C

0

D

Compilation error

Why: In Java, when an array is passed to a method, the reference to the array is passed by value. This means the method receives a copy of the reference, but both the original and the copy point to the same array object in heap memory. Therefore, modifying an element of the array inside the method (arr[0] = 99) directly changes the original array's content. When myArray[0] is printed after the call, it outputs 99.
Q4
easyFull explanation →

Which of the following correctly declares and initializes an array of strings with the elements "A", "B", and "C"?

A

String[] arr = new String[] {"A", "B", "C"};

B

String[] arr = ("A", "B", "C");

C

String[] arr = ["A", "B", "C"];

D

String[] arr = {"A", "B", "C"};

Correct shorthand initialization.

Why: Option D is correct because in Java, an array can be declared and initialized using the array initializer syntax with curly braces `{}` directly after the declaration, as in `String[] arr = {"A", "B", "C"};`. This is a shorthand that implicitly creates a new array object with the specified elements, and it is only valid in a declaration statement (not in an assignment to an already-declared variable).
Q5
mediumFull explanation →

A method 'public static int findMax(int[] numbers)' returns the maximum value in the array. Which implementation correctly handles an empty array by returning 0?

A

int max = 0; for(int n: numbers) if(n > max) max = n; return max;

B

int max = numbers[0]; for(int i=1; i<numbers.length; i++) if(numbers[i] > max) max = numbers[i]; return max;

C

if(numbers.length == 0) return 0; int max = 0; for(int n: numbers) if(n > max) max = n; return max;

D

if(numbers.length == 0) return 0; int max = numbers[0]; for(int i=1; i<numbers.length; i++) if(numbers[i] > max) max = numbers[i]; return max;

Correctly handles empty and non-empty arrays.

Why: Option D correctly handles an empty array by checking `numbers.length == 0` and returning 0 before attempting to access `numbers[0]`, which would throw an `ArrayIndexOutOfBoundsException` on an empty array. It then initializes `max` to the first element and iterates from index 1, ensuring all elements are compared correctly even if all numbers are negative.
Q6
hardFull explanation →

Given the method: 'public static void swapFirstTwo(int[] arr) { int temp = arr[0]; arr[0] = arr[1]; arr[1] = temp; }'. What is the effect of calling this method with an array of length 1?

A

An ArrayIndexOutOfBoundsException is thrown.

Index 1 is out of bounds for length 1.

B

The first element is swapped with itself.

C

A new array with length 2 is returned.

D

The array remains unchanged.

Why: The method accesses arr[0] and arr[1] without checking the array length. When called with an array of length 1, arr[1] does not exist, so the JVM throws an ArrayIndexOutOfBoundsException at runtime. This is because Java arrays are zero-indexed and bounds checking is performed at runtime.

Want more Arrays and Methods practice?

Practice this domain
6

Domain 6: Object-Oriented Programming

All Object-Oriented Programming questions
Q1
mediumFull explanation →

A developer writes a class 'Vehicle' with a method 'move()' that prints 'Vehicle moves'. A subclass 'Car' overrides 'move()' to print 'Car moves'. Given: Vehicle v = new Car(); v.move(); What is the output?

A

Vehicle moves

B

Runtime exception

C

Compilation fails

D

Car moves

Correct due to polymorphism; the overridden method in Car is called.

Why: Option D is correct because Java uses dynamic method dispatch (runtime polymorphism). Even though the reference variable is of type 'Vehicle', the actual object is a 'Car' instance. At runtime, the JVM calls the overridden 'move()' method of the 'Car' class, printing 'Car moves'.
Q2
easyFull explanation →

In a banking application, a class 'Account' has a private field 'balance'. Which is the best way to allow subclasses to read but not directly modify 'balance'?

A

Make balance public

B

Provide a public getBalance() method

Getter provides read-only access; keep field private.

C

Use a static variable

D

Make balance protected

Why: Option B is correct because it follows the encapsulation principle of object-oriented programming. By providing a public getBalance() method, subclasses can read the balance value without having direct access to the private field, thus preventing unintended modification. This is the standard Java pattern for controlled access to private instance variables.
Q3
hardFull explanation →

A class 'Base' has a method 'public void display() throws IOException'. Subclass 'Derived' overrides display(). Which exception specifications are allowed in the overriding method?

A

public void display() throws SQLException

B

public void display() throws FileNotFoundException

FileNotFoundException is a subclass of IOException, allowed.

C

public void display() throws Exception

D

public void display() throws Throwable

Why: In Java, an overriding method can throw the same exception, a subclass of the exception thrown by the parent method, or no exception at all. The parent method throws IOException, so the overriding method may throw FileNotFoundException (a subclass of IOException). This follows the rule that the overriding method cannot throw a broader checked exception than the overridden method.
Q4
mediumFull explanation →

Which design principle is violated by making all fields public in a class?

A

Inheritance

B

Abstraction

C

Encapsulation

Encapsulation hides internal data; public fields expose it.

D

Polymorphism

Why: Making all fields public violates the principle of encapsulation, which requires that an object's internal state be hidden from external access and only modifiable through controlled methods (getters/setters). In Java, public fields allow any class to directly read or modify the field, breaking data integrity and the ability to enforce invariants. Encapsulation is a core OOP concept that protects the internal representation of an object.
Q5
hardFull explanation →

Given: abstract class Shape { abstract void draw(); } class Circle extends Shape { void draw() {} } Which is true?

A

Shape cannot have a constructor

B

Circle must override draw()

Circle provides implementation; it compiles fine.

C

Shape s = new Shape(); is valid

D

draw() must be public in Circle

Why: Option B is correct because Circle is a concrete class that extends the abstract class Shape, which declares the abstract method draw(). A concrete subclass of an abstract class must provide an implementation for all inherited abstract methods, unless the subclass is also declared abstract. Circle provides an implementation of draw() with an empty body, which satisfies the override requirement.
Q6
easyFull explanation →

Which is the correct way to call a superclass constructor from a subclass constructor?

A

super(); anywhere

B

super(); as first statement

Correct syntax and position.

C

super(); at the end

D

this.super();

Why: In Java, a call to the superclass constructor using `super()` must be the first statement in a subclass constructor. This ensures that the superclass initialization completes before any subclass-specific code executes, maintaining the inheritance chain. Option B correctly identifies this requirement.

Want more Object-Oriented Programming practice?

Practice this domain
7

Domain 7: Exception Handling and Development Tools

All Exception Handling and Development Tools questions
Q1
mediumFull explanation →

A developer writes a method that reads a file and processes its contents. If the file does not exist, the method should notify the caller. Which exception should the method declare in its throws clause?

A

RuntimeException

B

FileNotFoundException

FileNotFoundException is a checked exception specifically for missing files.

C

Exception

D

IOException

Why: Option B is correct because `FileNotFoundException` is a checked exception that specifically indicates a file cannot be found at the specified path. The method must declare it in its `throws` clause to notify the caller that this condition can occur and must be handled or re-declared, as required by Java's checked exception rules.
Q2
hardFull explanation →

A team is developing a Java application that uses many third-party libraries. One library throws a checked exception that is not declared in its method signature. Which approach best handles this situation?

A

Ignore the exception because it is not declared.

B

Declare the library's exception in the method signature.

C

Wrap the exception in a RuntimeException and throw it.

This satisfies the compiler and preserves the exception chain.

D

Catch the exception and log it, then continue execution.

Why: Option C is correct because a checked exception that is not declared in a method signature cannot be propagated without handling it. Wrapping it in a RuntimeException (an unchecked exception) bypasses the compiler's checked-exception enforcement, allowing the exception to be thrown without modifying the method signature. This is a common pattern when integrating third-party libraries that throw checked exceptions from methods that do not declare them.
Q3
easyFull explanation →

Which of the following is the best practice for resource management in Java?

A

Close resources in a finally block without null checks.

B

Rely on garbage collection to close resources.

C

Use try-with-resources statement.

Try-with-resources automatically closes AutoCloseable resources.

D

Use a try-catch block and close resources in the catch block.

Why: Option C is correct because the try-with-resources statement (introduced in Java 7) automatically closes each resource declared in its header when the block exits, whether normally or due to an exception. This eliminates the need for explicit cleanup code and ensures that resources implementing `AutoCloseable` are closed reliably, preventing resource leaks.
Q4
hardFull explanation →

A developer encounters an ArrayIndexOutOfBoundsException while running a unit test. The stack trace shows the error occurs in a method that is called from many places. Which tool or technique would most efficiently identify the specific call path?

A

Review the code manually to trace all possible callers.

B

Set a breakpoint in the method and debug the test.

Debugging allows inspection of the call stack and variables.

C

Run a static analysis tool to detect the issue.

D

Add log statements at the beginning of the method.

Why: Setting a breakpoint in the method and debugging the test allows the developer to inspect the call stack at runtime, immediately revealing the exact sequence of method invocations that led to the ArrayIndexOutOfBoundsException. This is the most efficient approach because it directly captures the specific call path without requiring manual tracing or post-hoc analysis.
Q5
easyFull explanation →

Which statement about the Java compiler is true?

A

It translates Java source code into native machine code.

B

It produces executable files that run directly on the OS.

C

It executes Java programs.

D

It translates Java source code into bytecode.

javac produces .class files containing bytecode.

Why: The Java compiler (javac) translates human-readable Java source code (.java files) into platform-independent bytecode (.class files). This bytecode is then executed by the Java Virtual Machine (JVM), not directly by the operating system. Option D correctly identifies this translation step.
Q6
mediumFull explanation →

A method throws a checked exception. Which of the following is the correct way to handle it in the calling method?

A

Ignore the exception since it is checked.

B

Add a throws clause to the calling method.

C

Enclose the call in a try-catch block.

Catching the exception handles it.

D

Use a finally block without catch.

Why: Option C is correct because checked exceptions must be handled by the calling method either by catching them with a try-catch block or by declaring them in a throws clause. Since the question asks for the correct way to handle it, enclosing the call in a try-catch block is a valid and direct handling approach that prevents the exception from propagating unhandled.

Want more Exception Handling and Development Tools practice?

Practice this domain

Frequently asked questions

How many questions are on the 1Z0-811 exam?

The 1Z0-811 exam has 75 questions and must be completed in 75 minutes. The passing score is 650/1000.

What types of questions appear on the 1Z0-811 exam?

Scenario-based questions covering exam objectives with detailed answer explanations.

How are 1Z0-811 questions organised by domain?

The exam covers 7 domains: What is Java, Java Basics and Syntax, Primitives, Strings and Operators, Control Flow and Loops, Arrays and Methods, Object-Oriented Programming, Exception Handling and Development Tools. Questions are weighted by domain — higher-weight domains appear more on your actual exam.

Are these the actual 1Z0-811 exam questions?

No. These are original exam-style practice questions written against the official Oracle 1Z0-811 exam objectives. They are not copied from the real exam. Courseiva focuses on genuine understanding, not memorisation of braindumps.

Ready to practice all 75 1Z0-811 questions?

Courseiva tracks your accuracy per domain and routes you toward weak areas automatically. Free, no account required.

Browse all 1Z0-811 questionsTake a timed practice test