Sample questions
Oracle Java Foundations 1Z0-811 practice questions
Which THREE are primitive data types in Java? (Choose three.)
Refer to the exhibit. A Java program throws a NullPointerException. Which is the most likely cause?
Exception Handling and Development ToolsmediumSee the answer and why each option is right or wrong →A programmer is writing code that needs to store the result of a comparison that checks whether a number is greater than 10. Which primitive type should be used for the variable th…
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…
What is the output of the following code? int[] a = {1,2,3}; int[] b = a; b[0] = 99; System.out.println(a[0]);
A developer writes: int a = 9; int b = 2; double result = a / b; System.out.println(result); What is the output?
What is the output? ```java public class Test { public static void main(String[] args) { String s1 = "hello"; String s2 = "hello"; System.out.println(s…
A junior developer created a class 'BankAccount' with public fields for balance and account number. After deployment, users are able to set negative balances, causing issues. Which…
A developer is preparing to run a Java application on a colleague's computer. The colleague has installed the Java Runtime Environment (JRE) but not the Java Development Kit (JDK).…
A developer is reviewing code that declares several numeric variables. Which of the following declarations correctly assigns a floating-point literal to a variable of type float wi…
A logistics application needs to store a shipment's unique tracking code, which is a fixed 12-character alphanumeric identifier. The code must not be modified after it is assigned.…
Which of the following best demonstrates polymorphism in Java?
Which three of the following are valid ways to declare and initialize a variable of type int? (Choose three.)
A Java class named 'Helper' is defined in package 'utils'. Another class in a different package tries to access a public method of Helper but receives a compilation error. The Help…
What is the result of the following code? int[] arr = new int[3]; arr[3] = 5; System.out.println(arr[3]);
During execution, the JVM uses Just-In-Time (JIT) compilation. What is its primary benefit?
A company manages employee data stored in an array of Employee objects. The HR application frequently needs to find an employee by ID. The current implementation uses a linear sear…
Match each Java tool to its function.
Which loop construct guarantees that the loop body executes at least once?
Which TWO methods correctly modify the passed array in place?
A package named com.example.util is declared in a file. Where should the file be placed in the directory structure?
Arrange the steps to create and use a simple Java inheritance hierarchy in the correct order.
Given the stack trace above, which line in MyClass.java caused the exception? Exception in thread "main" java.lang.NullPointerException at MyClass.methodC(MyClass.java:25)…
Exception Handling and Development ToolsmediumSee the answer and why each option is right or wrong →Which of the following correctly uses the ternary operator to set int max to the larger of two ints x and y?