Oracle Certified Professional: Java SE 11 Developer (1Z0-819) — Questions and Answers
Question 1: What happens when you call Iterator.remove() before calling Iterator.next()?
- It throws NoSuchElementException
- It silently does nothing
- It removes the last element of the collection
- It throws IllegalStateException (Correct answer)
Correct answer: It throws IllegalStateException
Iterator.remove() requires a prior call to next(); calling remove() without it throws IllegalStateException.
Question 2: How does risk management apply to daily practice in Database Architecture & Administration for Oracle Certified Professional professionals?
- Only through responding to incidents after they occur
- Through proactive identification of potential hazards and implementation of preventive measures (Correct answer)
- Through annual safety audits exclusively
- By avoiding high-risk situations entirely
Correct answer: Through proactive identification of potential hazards and implementation of preventive measures
Effective risk management in Database Architecture & Administration requires proactive hazard identification and preventive measures, not just reactive responses. This approach reduces incidents, improves outcomes, and protects both professionals and clients.
Question 3: What does the `instanceof` operator return when tested against `null`?
- NullPointerException
- false (Correct answer)
- Compilation error
- true
Correct answer: false
`null instanceof AnyType` always returns `false` — no exception is thrown.
Question 4: What does List.copyOf(originalList) guarantee in Java 10+?
- A mutable deep copy of originalList
- An unmodifiable list containing the same elements in the same order (Correct answer)
- A lazy copy that reflects future changes to originalList
- A synchronized view of originalList
Correct answer: An unmodifiable list containing the same elements in the same order
List.copyOf() returns an unmodifiable List containing the elements of the given collection in encounter order; mutations to the original do not affect the copy.
Question 5: Which Oracle parameter enables automatic collection of real-time SQL statistics that feed into the SQL Monitoring facility?
- TIMED_OS_STATISTICS = 1
- STATISTICS_LEVEL = BASIC
- SQL_TRACE = TRUE
- STATISTICS_LEVEL = TYPICAL or ALL (Correct answer)
Correct answer: STATISTICS_LEVEL = TYPICAL or ALL
Setting STATISTICS_LEVEL to TYPICAL (default) or ALL enables collection of timed statistics required for SQL Monitoring and AWR.
Question 6: Which of the following best describes the core difference between intermediate and terminal operations in the Java Stream API?
- Intermediate operations are lazy and return a new stream, while terminal operations are eager and produce a result or side-effect. (Correct answer)
- Intermediate operations, like `map()` and `filter()`, can only be chained once, whereas terminal operations can be chained multiple times.
- Terminal operations can only be applied to parallel streams, while intermediate operations work for both sequential and parallel streams.
- Intermediate operations are optional, while every stream pipeline must end with a terminal operation.
Correct answer: Intermediate operations are lazy and return a new stream, while terminal operations are eager and produce a result or side-effect.
The key distinction lies in their execution behavior. Intermediate operations (e.g., `filter`, `map`, `sorted`) are lazy; they don't execute until a terminal operation is invoked. They build up a pipeline of transformations, each returning a new `Stream`. Terminal operations (e.g., `forEach`, `collect`, `reduce`) are eager, triggering the processing of the entire pipeline and producing a final result, such as a collection, a single value, or a side-effect. Once a terminal operation is called, the stream is considered consumed and cannot be reused.
Question 7: What is the final value returned by the `checkValue` method when executed? ```java public class Test { public static int checkValue() { try { System.out.println("Executing try"); return 10; } catch (Exception e) { System.out.println("Executing catch"); return 20; } finally { System.out.println("Executing finally"); return 30; } } public static void main(String[] args) { System.out.println("Returned: " + checkValue()); } } ```
- 30 (Correct answer)
- 10
- The code will not compile because a `finally` block cannot have a `return` statement.
- 20
Correct answer: 30
The `finally` block is always executed after the `try` block exits. If a `finally` block includes a `return` statement, it will override any value that was about to be returned from the `try` or `catch` block. In this case, the `try` block prepares to return 10, but the `finally` block executes and its `return` statement overrides the previous one, causing the method to return 30.
Question 8: Which collector groups stream elements into a Map<Boolean, List<T>>?
- Collectors.counting()
- Collectors.partitioningBy(Predicate) (Correct answer)
- Collectors.toMap(Function, Function)
- Collectors.groupingBy(Function)
Correct answer: Collectors.partitioningBy(Predicate)
Collectors.partitioningBy(Predicate) divides stream elements into exactly two groups (true/false) and returns a Map<Boolean, List<T>>.
Question 9: Given the following code snippet, what is the output? ```java List<String> list = Arrays.asList("a", "b", "c"); Optional<String> result = list.stream() .filter(s -> s.equals("d")) .findFirst(); System.out.println(result.orElse("Not Found")); ```
- null
- A NoSuchElementException is thrown
- Not Found (Correct answer)
- An empty Optional
Correct answer: Not Found
The stream is filtered for the string "d", which does not exist in the list. Therefore, the `filter` operation results in an empty stream. The `findFirst()` terminal operation on an empty stream returns an empty `Optional`. The `orElse("Not Found")` method is then called on this empty `Optional`, which causes it to return the provided default value, "Not Found". A `NoSuchElementException` would only be thrown if `get()` were called on an empty `Optional` without checking for presence.
Question 10: What happens when you call a terminal operation on a stream that has already been consumed?
- An empty result is returned
- IllegalStateException is thrown at runtime (Correct answer)
- A new stream is automatically created
- The stream resets and re-processes from the start
Correct answer: IllegalStateException is thrown at runtime
Streams cannot be reused; calling a second terminal operation on an already-consumed stream throws IllegalStateException.
Question 11: What is the result of adding a duplicate element to a HashSet?
- The set grows to hold both copies
- The add() method returns false and the set remains unchanged (Correct answer)
- The duplicate replaces the original element
- It throws an IllegalArgumentException
Correct answer: The add() method returns false and the set remains unchanged
Set.add() returns false without modifying the set when the element already exists (as determined by equals() and hashCode()).
Question 12: Which statement about `assert` with a detail message is correct?
- assert condition, message; — message only evaluated if assertion fails (Correct answer)
- assert(condition, message); — correct syntax with parentheses
- assert condition : message; — message is evaluated before the condition
- assert condition, message; — message always evaluated
Correct answer: assert condition, message; — message only evaluated if assertion fails
In `assert condition : message;`, the message expression is only evaluated when the assertion fails, making it lazy.
Question 13: Which of the following exceptions is a checked exception that the Java compiler requires to be handled or declared?
- ArrayIndexOutOfBoundsException
- ClassCastException
- NullPointerException
- java.io.FileNotFoundException (Correct answer)
Correct answer: java.io.FileNotFoundException
`FileNotFoundException` is a subclass of `IOException`, which is a checked exception. The Java compiler enforces that checked exceptions must be either caught in a try-catch block or declared in the method signature with a `throws` clause. The other options (`NullPointerException`, `ArrayIndexOutOfBoundsException`, `ClassCastException`) are all subclasses of `RuntimeException` and are therefore unchecked exceptions.
Question 14: What happens when a class is declared `abstract` and contains no abstract methods?
- Compilation error
- Only static methods are allowed
- The class cannot be instantiated but can be subclassed (Correct answer)
- It behaves exactly like a concrete class
Correct answer: The class cannot be instantiated but can be subclassed
An abstract class with no abstract methods is valid — it simply cannot be instantiated directly.
Question 15: A module named `com.app` contains package `com.app.internal`. Which declaration restricts its export to only `com.trusted` module?
- requires com.trusted;
- exports com.app.internal to com.trusted; (Correct answer)
- exports com.app.internal;
- opens com.app.internal to com.trusted;
Correct answer: exports com.app.internal to com.trusted;
The `exports ... to` qualified export restricts which specific modules can access the exported package.
Question 16: What does Collectors.joining(", ") do when used with Stream.collect()?
- Joins two streams together
- Collects elements into a List joined as comma-separated values
- Groups elements into a Map by a delimiter
- Concatenates stream elements into a single String separated by ", " (Correct answer)
Correct answer: Concatenates stream elements into a single String separated by ", "
Collectors.joining(delimiter) concatenates all CharSequence elements of a stream into a single String with the given delimiter between each element.
Question 17: What is the function of the PMON (Process Monitor) background process in Oracle?
- Monitors physical I/O to datafiles and generates alerts
- Propagates SCN changes across RAC nodes
- Writes statistics to AWR at regular intervals
- Cleans up resources from failed user processes and rolls back their transactions (Correct answer)
Correct answer: Cleans up resources from failed user processes and rolls back their transactions
PMON detects failed user processes and cleans up their resources, including releasing locks, rolling back uncommitted transactions, and freeing SGA resources.
Question 18: Which of the following is true about the `finally` block in Java?
- It prevents exceptions from propagating
- It executes only if no exception is thrown
- It executes even if a return statement is in the try block (Correct answer)
- It only executes when an exception is thrown
Correct answer: It executes even if a return statement is in the try block
The finally block always executes after try/catch completion, even if a return statement is encountered in the try block.
Question 19: What exception is thrown when a ConcurrentModificationException occurs?
- It is thrown when two threads write to the same collection simultaneously
- It is thrown when Collections.synchronizedList() detects a race condition
- It is thrown when a collection is modified while iterating over it with a fail-fast iterator (Correct answer)
- It is thrown when an index is out of bounds during concurrent access
Correct answer: It is thrown when a collection is modified while iterating over it with a fail-fast iterator
Fail-fast iterators (like those of ArrayList) throw ConcurrentModificationException if the collection is structurally modified during iteration outside of the iterator itself.
Question 20: What is the difference between findFirst() and findAny() on a sequential stream?
- findFirst() returns the last element, findAny() returns the first
- On sequential streams they behave identically, always returning the first element (Correct answer)
- findFirst() blocks until the stream is fully consumed
- findAny() is only available on parallel streams
Correct answer: On sequential streams they behave identically, always returning the first element
On sequential streams both findFirst() and findAny() return the first element encountered; the distinction matters only for parallel streams where findAny() may return any element for performance.
Question 21: What does the GATHER_PLAN_STATISTICS hint do when added to a SQL query in Oracle?
- Triggers an automatic AWR snapshot at query end
- Forces the optimizer to re-gather table statistics before planning
- Updates the PLAN_TABLE with estimated statistics
- Collects actual row counts and elapsed time per operation during execution, visible in V$SQL_PLAN_STATISTICS (Correct answer)
Correct answer: Collects actual row counts and elapsed time per operation during execution, visible in V$SQL_PLAN_STATISTICS
GATHER_PLAN_STATISTICS captures actual execution metrics per plan operation, which can be viewed via DBMS_XPLAN.DISPLAY_CURSOR with the 'ALLSTATS LAST' format option.
Question 22: Which command enables block change tracking for faster RMAN incremental backups?
- ALTER SYSTEM SET BLOCK_CHANGE_TRACKING=TRUE
- CONFIGURE CHANGE TRACKING ON
- ALTER DATABASE ENABLE BLOCK CHANGE TRACKING USING FILE '/path/bct.f' (Correct answer)
- RMAN> ENABLE BLOCK CHANGE TRACKING
Correct answer: ALTER DATABASE ENABLE BLOCK CHANGE TRACKING USING FILE '/path/bct.f'
ALTER DATABASE ENABLE BLOCK CHANGE TRACKING creates the change tracking file and activates the CTWR background process.
Question 23: Which JVM flag enables assertions for a specific class named `com.example.MyClass`?
- Both A and B are correct (Correct answer)
- -enableassertions:com.example.MyClass
- -ea com.example.MyClass
- -ea:com.example.MyClass
Correct answer: Both A and B are correct
Both -ea and -enableassertions are equivalent flags and can be used with a class name to enable assertions for that specific class.
Question 24: Which of the following statements most accurately describes a primary difference between `java.util.concurrent.CyclicBarrier` and `java.util.concurrent.CountDownLatch`?
- `CyclicBarrier` is limited to coordinating exactly two threads, while `CountDownLatch` can coordinate any number of threads.
- Only `CountDownLatch` allows a timeout to be specified when waiting.
- `CountDownLatch` is designed for a single use, whereas `CyclicBarrier` can be reset and reused after all waiting threads are released. (Correct answer)
- Threads wait on a `CyclicBarrier` by calling `countDown()`, and on a `CountDownLatch` by calling `await()`.
Correct answer: `CountDownLatch` is designed for a single use, whereas `CyclicBarrier` can be reset and reused after all waiting threads are released.
The most significant difference is that a `CyclicBarrier` is reusable. After the barrier is tripped (all parties have arrived), it can be reset to its initial state, either automatically or by calling `reset()`, for another round of coordination. A `CountDownLatch` is a one-time-use synchronizer; once its count reaches zero, it cannot be reset.
Question 25: What does Oracle Data Redaction do to sensitive data when a user queries a protected column?
- Encrypts the stored value before returning it
- Masks the value in query results without altering stored data (Correct answer)
- Raises an error and denies access to the column
- Permanently deletes the sensitive value
Correct answer: Masks the value in query results without altering stored data
Oracle Data Redaction dynamically replaces sensitive column values in query output while leaving the actual stored data unchanged.
Question 26: Which RMAN command is used to validate a backup without actually restoring it?
- RESTORE VALIDATE
- CHECK BACKUP
- RESTORE DATABASE VALIDATE (Correct answer)
- VALIDATE BACKUPSET
Correct answer: RESTORE DATABASE VALIDATE
RESTORE DATABASE VALIDATE checks whether backups exist and are usable without writing any data files.
Question 27: What does the PL/SQL keyword 'EXCEPTION' handle?
- It terminates the program
- It handles runtime errors (Correct answer)
- It stores user inputs
- It stores data in a backup file
Correct answer: It handles runtime errors
The PL/SQL keyword `EXCEPTION` is used to define a section within a PL/SQL block dedicated to handling runtime errors. When an error occurs during the execution of the `BEGIN` section, control is transferred to the `EXCEPTION` section. This allows the program to gracefully manage the error, log it, or take corrective actions instead of crashing.
Question 28: When using `@Override`, what happens if the method signature does not match any method in the superclass or interface?
- A compilation error occurs (Correct answer)
- The annotation is ignored
- The method overloads the parent method
- A runtime warning is issued
Correct answer: A compilation error occurs
`@Override` causes a compile-time error if the annotated method does not actually override a superclass or interface method.
Question 29: Which view provides information about the current guaranteed restore points in an Oracle database?
- V$RESTORE_POINT (Correct answer)
- V$FLASHBACK_DATABASE_LOG
- V$GUARANTEED_RESTORE_POINT
- DBA_RESTORE_POINTS
Correct answer: V$RESTORE_POINT
V$RESTORE_POINT lists all restore points (normal and guaranteed), including their SCN, time, and whether guaranteed mode is active.
Question 30: Which Oracle security feature encrypts tablespaces and data files at the storage level without requiring application changes?
- Oracle Data Masking
- Transparent Data Encryption (TDE) (Correct answer)
- Oracle Data Redaction
- Oracle Advanced Security Gateway
Correct answer: Transparent Data Encryption (TDE)
Transparent Data Encryption (TDE) encrypts data at rest in tablespaces and data files, remaining invisible to the application.
Question 31: What is the result of compiling and running the following code? ```java List<String> list = new ArrayList<>(); list.add("A"); List<Object> objList = list; objList.add(42); System.out.println(list.get(1)); ```
- Compile error: incompatible types (Correct answer)
- ClassCastException at runtime
- Prints 42
- Prints null
Correct answer: Compile error: incompatible types
A List<String> cannot be assigned to List<Object> because generic types are invariant in Java, causing a compile-time error.
Question 32: What does the Collections.unmodifiableList() method return?
- A view that throws UnsupportedOperationException on mutation (Correct answer)
- A deep-cloned list with no backing reference
- A synchronized wrapper around the list
- A new immutable copy of the list
Correct answer: A view that throws UnsupportedOperationException on mutation
Collections.unmodifiableList() returns a view backed by the original list; structural modifications through the view throw UnsupportedOperationException.
Question 33: Which method converts an IntStream to a Stream<Integer>?
- boxed() (Correct answer)
- mapToObj(i -> i)
- toStream()
- asStream()
Correct answer: boxed()
IntStream.boxed() is a convenience method equivalent to mapToObj(Integer::valueOf) that returns a Stream<Integer>.
Question 34: Which stream operation is guaranteed to be stateful and may require processing the entire stream before producing output?
- peek()
- filter()
- map()
- sorted() (Correct answer)
Correct answer: sorted()
sorted() is a stateful intermediate operation because it must examine all elements to determine their order before emitting any results.
Question 35: In Oracle, what is the effect of setting the AUTOEXTEND ON clause when creating a datafile?
- The datafile grows automatically when space runs out (Correct answer)
- The datafile is automatically backed up when full
- The datafile is striped across multiple disks automatically
- The tablespace switches to a new datafile when the current one is full
Correct answer: The datafile grows automatically when space runs out
AUTOEXTEND ON allows Oracle to automatically increase the datafile size when the tablespace runs out of free space, up to the specified MAXSIZE.
Question 36: When using `synchronized` on an instance method, which object is used as the monitor lock?
- A dedicated lock object created by the JVM
- The thread calling the method
- The instance (`this`) on which the method is called (Correct answer)
- The class object of the declaring class
Correct answer: The instance (`this`) on which the method is called
An instance `synchronized` method acquires the intrinsic lock on `this`, the object the method is invoked on.
Question 37: What is the purpose of the peek() intermediate operation?
- To stop the stream at a given element
- To collect elements into a temporary list
- To inspect elements for debugging without altering the stream pipeline (Correct answer)
- To transform each element into another type
Correct answer: To inspect elements for debugging without altering the stream pipeline
peek(Consumer) is an intermediate operation designed primarily for debugging that performs an action on each element while passing them through unchanged.
Question 38: Which terminal operation returns an OptionalDouble representing the average of a DoubleStream?
- sum()
- reduce()
- mean()
- average() (Correct answer)
Correct answer: average()
DoubleStream.average() is a terminal operation that returns OptionalDouble containing the arithmetic mean of all elements.
Question 39: Which Oracle memory structure caches the parsed representations of SQL statements and PL/SQL code?
- Database buffer cache
- Java pool
- Large pool
- Library cache (within the shared pool) (Correct answer)
Correct answer: Library cache (within the shared pool)
The library cache, a component of the shared pool, stores parsed SQL cursors and execution plans to enable soft parses.
Question 40: What is printed by: `int x = 0; try { x = 1; return x; } finally { x = 2; System.out.print(x); }`?
- 2 (Correct answer)
- 0
- 1
- Compilation error
Correct answer: 2
The finally block executes before the return completes, so x=2 is assigned and printed as '2', though the method returns 1.
Question 41: What does Collectors.groupingBy(Function, Collectors.counting()) produce?
- Map<K, List<T>>
- Map<K, Integer>
- Map<K, Long> (Correct answer)
- Map<K, Optional<Long>>
Correct answer: Map<K, Long>
groupingBy with a downstream counting() collector produces a Map where each key maps to the Long count of elements in that group.
Question 42: What is the effect of the following code? ```java List<Integer> src = Arrays.asList(1, 2, 3); List<Integer> dst = Arrays.asList(0, 0, 0); Collections.copy(dst, src); System.out.println(dst); ```
- UnsupportedOperationException at runtime
- IndexOutOfBoundsException at runtime
- [1, 2, 3] (Correct answer)
- [0, 0, 0]
Correct answer: [1, 2, 3]
Collections.copy() copies src into dst in-place; Arrays.asList returns a fixed-size but mutable list, so set() works and dst becomes [1, 2, 3].
Question 43: Which SQL clause would you add to prevent phantom reads in a query used inside a long-running PL/SQL procedure?
- LOCK TABLE
- AS OF SCN (Correct answer)
- FOR UPDATE
- WITH READ ONLY
Correct answer: AS OF SCN
AS OF SCN (or AS OF TIMESTAMP) queries Flashback data at a specific point in time, ensuring a consistent read snapshot throughout the procedure.
Question 44: Which Oracle process is responsible for performing background database tasks like recovery and managing transactions?
- PMON
- SMON
- DBWR (Correct answer)
- LGWR
Correct answer: DBWR
The Database Writer (DBWR) background process is responsible for writing modified data blocks from the database buffer cache to the data files on disk. This process ensures that changes made in memory are persistently stored, managing the flow of data from the volatile memory to stable storage. While SMON and PMON are also background processes, DBWR specifically handles writing dirty buffers.
Question 45: What is the result when an abstract class implements an interface but does not implement all of its methods?
- The JVM provides default empty implementations
- Compilation error
- Only unimplemented methods with default body are allowed
- The unimplemented methods become abstract in the abstract class (Correct answer)
Correct answer: The unimplemented methods become abstract in the abstract class
An abstract class is not required to implement all interface methods; unimplemented methods remain abstract and must be implemented by the first concrete subclass.
Question 46: Which generic wildcard should be used in a method signature `void process(List<?> list)` to allow the method to add `Integer` objects to the list?
- List<?>
- List<? super Integer> (Correct answer)
- List<Object>
- List<? extends Number>
Correct answer: List<? super Integer>
The `? super Integer` wildcard, known as a lower-bounded wildcard, restricts the unknown type to be a supertype of `Integer` (or `Integer` itself). This allows you to safely add `Integer` objects (or subtypes of `Integer`, though `Integer` is final) to the collection, as they will always be compatible with the list's actual type. An upper-bounded wildcard (`? extends T`) is for reading, and an unbounded wildcard (`?`) is also primarily for reading as the compiler cannot guarantee what type is safe to add.
Question 47: What is a key characteristic of a lambda expression captured variable in Java?
- It can be freely reassigned inside the lambda
- It must be a class-level field
- It must be declared with the final keyword
- It must be effectively final (Correct answer)
Correct answer: It must be effectively final
Lambda expressions can capture local variables from the enclosing scope only if those variables are final or effectively final (never reassigned after initialization).
Question 48: Which exception class must be the parent when creating a custom checked exception?
- Exception (but not RuntimeException) (Correct answer)
- Throwable directly
- Error
- RuntimeException
Correct answer: Exception (but not RuntimeException)
A custom checked exception must extend Exception or one of its subclasses that is not RuntimeException or Error.
Question 49: Which scenario would cause a `ClassCastException` at runtime?
- Casting a parent reference to a child type when the object is not actually an instance of that child (Correct answer)
- Assigning a child object to a parent reference
- Casting an object to its own class
- Casting an int to a long
Correct answer: Casting a parent reference to a child type when the object is not actually an instance of that child
Casting a reference to a subtype when the object is not actually of that subtype throws `ClassCastException` at runtime.
Question 50: What does it mean for an Oracle tablespace to be in 'read-only' mode?
- Users cannot query data in the tablespace
- DBWR stops writing to the tablespace's datafiles
- The tablespace is automatically archived
- No DML or DDL can modify objects in the tablespace, but queries are permitted (Correct answer)
Correct answer: No DML or DDL can modify objects in the tablespace, but queries are permitted
A read-only tablespace allows SELECT queries but prevents any INSERT, UPDATE, DELETE, or DDL operations that would modify its contents.
Question 51: What is the purpose of Oracle's Adaptive Query Optimization introduced in Oracle 12c?
- It rewrites queries automatically to use materialized views
- It allows the optimizer to adjust execution plans mid-execution based on actual row counts observed (Correct answer)
- It enables automatic index creation during query execution
- It parallelizes single-pass queries into multi-pass operations
Correct answer: It allows the optimizer to adjust execution plans mid-execution based on actual row counts observed
Adaptive Query Optimization allows Oracle to modify execution plans during runtime when actual row counts differ significantly from optimizer estimates.
Question 52: Which interface must a class implement so its instances can be stored in a TreeSet without a Comparator?
- java.lang.Cloneable
- java.lang.Comparable (Correct answer)
- java.util.Comparator
- java.io.Serializable
Correct answer: java.lang.Comparable
TreeSet requires elements to implement Comparable (specifically compareTo()) for natural ordering unless an explicit Comparator is supplied.
Question 53: In Oracle Label Security, which component defines the hierarchical sensitivity ranking of data (e.g., SENSITIVE, HIGHLY_SENSITIVE)?
- Compartment
- Policy
- Level (Correct answer)
- Group
Correct answer: Level
In Oracle Label Security, a Level defines the sensitivity rank of data in the label hierarchy, from least to most sensitive.
Question 54: A developer is working with a `Stream<String>` and wants to produce a `Map<Integer, List<String>>` where the keys are the lengths of the strings and the values are lists of strings of that length. Which `Collector` should be used?
- Collectors.groupingBy(String::length) (Correct answer)
- Collectors.toMap(s -> s.length(), s -> List.of(s), (list1, list2) -> list1)
- Collectors.partitioningBy(s -> s.length() > 0)
- Collectors.toMap(String::length, s -> s)
Correct answer: Collectors.groupingBy(String::length)
The `Collectors.groupingBy()` collector is specifically designed for this purpose. It takes a classifier function (in this case, `String::length`) and groups the elements of the stream into a `Map`. The keys of the map are the results of applying the classifier function, and the values are `List`s containing the elements that mapped to that key. `Collectors.partitioningBy` only separates elements into two groups based on a `Predicate`. The `toMap` collectors would throw an `IllegalStateException` on duplicate keys (strings with the same length) without a merge function, and the provided merge function in the incorrect option is flawed.
Question 55: What is the correct way to create an unmodifiable Map with three entries in Java 9+?
- Map.copyOf(Map.entry("a",1))
- new ImmutableMap<>("a",1,"b",2,"c",3)
- Map.of("a",1,"b",2,"c",3) (Correct answer)
- Collections.unmodifiableMap(new HashMap<>(){{put("a",1);}})
Correct answer: Map.of("a",1,"b",2,"c",3)
Map.of() (introduced in Java 9) creates an immutable map with up to 10 key-value pairs specified inline without helper classes.
Question 56: What is the purpose of the `--patch-module` option when running a Java application?
- Converts a named module to an automatic module
- Merges additional classes into an existing module at runtime (Correct answer)
- Patches security vulnerabilities in platform modules
- Updates the JDK module to a newer version
Correct answer: Merges additional classes into an existing module at runtime
`--patch-module` injects additional classes or resources into a named module, overriding or augmenting its content at runtime.
Question 57: Which of the following correctly declares a bounded generic class that only accepts Number subclasses?
- class Box<Number T> {}
- class Box<? extends Number> {}
- class Box<T super Number> {}
- class Box<T extends Number> {} (Correct answer)
Correct answer: class Box<T extends Number> {}
An upper-bounded type parameter on a class uses `<T extends Number>`, restricting T to Number itself or any subclass like Integer or Double.
Question 58: Which audit policy type in Oracle captures access only when a query returns rows matching a specific condition?
- Mandatory auditing
- Fine-Grained Auditing (FGA) (Correct answer)
- Standard auditing
- SYS.AUD$ auditing
Correct answer: Fine-Grained Auditing (FGA)
Fine-Grained Auditing (FGA) triggers audit records only when query results include rows that satisfy the FGA policy's condition.
Question 59: Which view shows the status of RMAN backup jobs currently running?
- V$RMAN_JOBS
- V$RMAN_STATUS
- V$BACKUP_JOB
- V$SESSION_LONGOPS (Correct answer)
Correct answer: V$SESSION_LONGOPS
V$SESSION_LONGOPS tracks long-running operations including RMAN backup and restore jobs, showing estimated time remaining.
Question 60: In a multi-catch block `catch (IOException | SQLException e)`, what is the type of `e`?
- SQLException
- The common supertype of both exceptions (Correct answer)
- Object
- IOException
Correct answer: The common supertype of both exceptions
In a multi-catch, the variable type is the most specific common supertype of all the listed exception types.
Question 61: Which Oracle background process performs space management tasks such as coalescing free extents in tablespaces using dictionary extent management?
- PMON
- SMON (Correct answer)
- MMON
- CKPT
Correct answer: SMON
SMON (System Monitor) performs instance recovery at startup and handles space management including coalescing free space in dictionary-managed tablespaces.
Question 62: What are 'suppressed exceptions' in Java?
- Exceptions thrown during resource closing that are added to the primary exception (Correct answer)
- Exceptions thrown in catch blocks that are ignored
- Exceptions silenced by the compiler
- Exceptions from finally blocks that replace the original
Correct answer: Exceptions thrown during resource closing that are added to the primary exception
When a resource's close() throws an exception while another exception is propagating, the close() exception is suppressed and attached to the primary exception.
Question 63: What is the AWR retention period default setting in Oracle Database?
- 30 days
- 3 days
- 14 days
- 7 days (Correct answer)
Correct answer: 7 days
By default, Oracle AWR retains performance snapshots for 7 days before purging them automatically.
Question 64: Which statement correctly describes how HashMap handles hash collisions in Java 8+?
- It chains colliding entries in a linked list, switching to a red-black tree when the bin reaches 8 entries (Correct answer)
- It throws an exception when two keys hash to the same bucket
- It uses a secondary hash function to find an empty bucket
- It uses open addressing with linear probing
Correct answer: It chains colliding entries in a linked list, switching to a red-black tree when the bin reaches 8 entries
Java 8+ HashMap uses chaining (linked list per bucket) and converts a bucket to a balanced tree when it exceeds a threshold of 8 entries, improving worst-case lookup from O(n) to O(log n).
Question 65: Which initialization parameter controls the total size of the System Global Area (SGA)?
- MEMORY_TARGET
- SGA_TARGET (Correct answer)
- DB_CACHE_SIZE
- SHARED_POOL_SIZE
Correct answer: SGA_TARGET
SGA_TARGET enables Automatic Shared Memory Management (ASMM) and sets the total SGA size.
Question 66: Which of the following statements about the `assert` keyword in Java is true?
- Assertions are a replacement for standard exception handling for public methods.
- An `AssertionError` is a checked exception that must be caught or declared.
- Assertions are enabled by default and must be disabled with the `-da` flag.
- Assertions can be enabled at runtime using the `-ea` flag and are primarily intended for debugging and testing. (Correct answer)
Correct answer: Assertions can be enabled at runtime using the `-ea` flag and are primarily intended for debugging and testing.
Assertions are disabled by default and are not meant to replace standard exception handling. They are intended for developers to verify internal invariants during development and testing. They can be enabled with the JVM flag `-ea` or `-enableassertions`. If an assertion fails, it throws an `AssertionError`, which is a subclass of `Error` (an unchecked throwable), not a checked exception.
Question 67: Which functional interface has the signature T apply(T t1, T t2)?
- BiConsumer<T,T>
- BinaryOperator<T> (Correct answer)
- UnaryOperator<T>
- BiFunction<T,T,T>
Correct answer: BinaryOperator<T>
BinaryOperator<T> extends BiFunction<T,T,T> and represents an operation on two operands of the same type, producing a result of the same type.
Question 68: Which statement about generic type bounds is TRUE?
- `<T extends Runnable & Serializable>` is valid (Correct answer)
- `<T extends Runnable, Serializable>` is valid
- A type parameter can extend multiple classes
- `<T super Object>` is valid in a class declaration
Correct answer: `<T extends Runnable & Serializable>` is valid
A type parameter can extend one class and multiple interfaces using `&` as separator; `<T extends Runnable & Serializable>` is valid syntax.
Question 69: A developer is creating a high-performance, thread-safe counter for a heavily used application. Which approach is generally preferred over using a `synchronized` method for a simple atomic increment operation?
- Wrapping the integer in a `Collections.synchronizedMap`.
- Declaring the primitive integer counter as `volatile`.
- Using a `ReentrantLock` to protect the increment operation.
- Using the `incrementAndGet()` method of `java.util.concurrent.atomic.AtomicInteger`. (Correct answer)
Correct answer: Using the `incrementAndGet()` method of `java.util.concurrent.atomic.AtomicInteger`.
`AtomicInteger` is specifically designed for this purpose. It uses low-level, non-blocking hardware instructions like Compare-And-Swap (CAS) to perform atomic operations. Under low to moderate contention, this is typically more performant than using a `synchronized` block or a `ReentrantLock`, which involves thread blocking and context switching overhead. A `volatile` variable only guarantees visibility, not atomicity for a read-modify-write operation like incrementing.
Question 70: Which access modifier makes a member visible only within the same package and to subclasses in other packages?
- package-private (no modifier)
- public
- private
- protected (Correct answer)
Correct answer: protected
`protected` grants access within the same package and to subclasses regardless of package.
Question 71: Which SQL function returns the number of months between two dates?
- DATE_DIFF
- DATEDIFF
- INTERVAL_MONTHS
- MONTHS_BETWEEN (Correct answer)
Correct answer: MONTHS_BETWEEN
MONTHS_BETWEEN(date1, date2) returns the number of months between two date values.
Question 72: In RMAN, what does the UNTIL SCN clause specify during a point-in-time recovery?
- The last applied redo log sequence number
- The exact system change number at which recovery should stop (Correct answer)
- The number of archive logs to apply
- The time in seconds after which recovery stops
Correct answer: The exact system change number at which recovery should stop
UNTIL SCN tells RMAN to recover the database and apply redo up to but not including the specified System Change Number.
Question 73: Which of the following creates a lazy infinite stream of random doubles?
- Stream.of(Math::random)
- DoubleStream.builder().build()
- Stream.iterate(0.0, Math::random)
- Stream.generate(Math::random) (Correct answer)
Correct answer: Stream.generate(Math::random)
Stream.generate(Supplier<T>) produces an infinite sequential unordered stream where each element is generated by the provided Supplier.
Question 74: Which wildcard allows reading elements from a generic collection without writing to it?
- List<T>
- List<? super T>
- List<Object>
- List<? extends T> (Correct answer)
Correct answer: List<? extends T>
An upper-bounded wildcard `? extends T` permits reading as T but prevents adding elements (except null), enforcing producer semantics.
Question 75: Which Oracle initialization parameter, when set to MEMORY_TARGET, enables Automatic Memory Management that tunes both SGA and PGA automatically?
- PGA_AGGREGATE_TARGET
- SGA_TARGET
- AMM_ENABLED
- MEMORY_TARGET (Correct answer)
Correct answer: MEMORY_TARGET
Setting MEMORY_TARGET enables Automatic Memory Management (AMM), where Oracle automatically tunes both SGA and PGA components within the specified total memory limit.
Question 76: What exception is thrown when a thread waiting on a `Future.get()` is interrupted?
- TimeoutException
- InterruptedException (Correct answer)
- ExecutionException
- CancellationException
Correct answer: InterruptedException
`Future.get()` throws `InterruptedException` if the current thread is interrupted while waiting for the computation.
Question 77: What is the result of Optional.empty().orElseGet(() -> "default")?
- null
- "default" (Correct answer)
- Optional["default"]
- NoSuchElementException
Correct answer: "default"
orElseGet(Supplier) returns the Supplier's result when the Optional is empty, so it returns the string "default".
Question 78: What is the PRIMARY purpose of continuing education requirements in Backup, Recovery & Data Guard for OCP professionals?
- Fulfilling mandatory regulatory requirements only
- Maintaining current knowledge and competency as the field evolves (Correct answer)
- Networking with other professionals in the field
- Earning additional credentials for career advancement
Correct answer: Maintaining current knowledge and competency as the field evolves
Continuing education in Backup, Recovery & Data Guard ensures professionals maintain current knowledge and skills as standards, technologies, and best practices evolve in the Oracle Certified Professional field.
Question 79: During incomplete recovery, after restoring datafiles to an earlier SCN, which command finalizes the database and resets the redo log sequence?
- ALTER DATABASE ACTIVATE STANDBY
- ALTER DATABASE OPEN NORESETLOGS
- ALTER DATABASE OPEN RESETLOGS (Correct answer)
- RECOVER DATABASE COMPLETE
Correct answer: ALTER DATABASE OPEN RESETLOGS
OPEN RESETLOGS must be used after incomplete (point-in-time) recovery to reset the online redo log sequence and open the database.
Question 80: What is the result of the following stream pipeline? ```java long count = Stream.of("apple", "banana", "apricot", "cherry") .filter(s -> s.startsWith("a")) .peek(System.out::println) .count(); ```
- The code will print "apple" and "apricot", and `count` will be 2. (Correct answer)
- The code will print nothing, and `count` will be 2.
- The code will print "apple", "banana", "apricot", and "cherry", and `count` will be 4.
- The code will not compile because `peek` is a terminal operation.
Correct answer: The code will print "apple" and "apricot", and `count` will be 2.
The stream pipeline first filters the elements, keeping only those that start with "a" ("apple", "apricot"). The `peek()` operation is an intermediate operation that performs an action on each element as it passes through the stream; in this case, it prints the element. Since `peek` is an intermediate operation, it doesn't terminate the stream. Finally, the `count()` terminal operation is called, which consumes the stream and returns the number of elements remaining after the filter, which is 2. The `peek` operation will execute for each of those 2 elements.
Oracle Certified Professional: Java SE 11 Developer (1Z0-819)
This certification validates expertise in Java SE 11 programming language, including object-oriented programming, concurrency, and functional programming.
Exam Rules
- You can skip questions and return to them later
- Flag questions for review before submitting
- No feedback shown until you submit the entire exam
- Unanswered questions count as wrong — answer everything
- 10 pretest questions are mixed in and don't affect your score
- Timer auto-submits when time runs out
- Your progress is auto-saved every 30 seconds