Oracle Certified Professional: Java SE 11 Developer (1Z0-819) — Questions and Answers
Question 1: Which `javac` flag is required to compile code in a single named module when the module-info.java is in the source root?
- --module-version
- --module-source-path . (Correct answer)
- --module com.mymodule
- --source-root .
Correct answer: --module-source-path .
`--module-source-path .` tells the compiler to find module source directories under the current path, enabling single or multi-module compilation.
Question 2: An application is launched with `app.jar` on the module path and a required `lib.jar` on the classpath. The module within `app.jar` does not have any special command-line flags applied. What is the expected outcome at runtime when code in `app.jar` attempts to access a class from `lib.jar`?
- The access will succeed, but the JVM will issue a warning about an 'unnamed module' being accessed.
- The access will succeed, as the classpath content is automatically available to all modules.
- The access will fail with a `NoClassDefFoundError` or similar error. (Correct answer)
- The access will succeed only if `lib.jar` is also an automatic module.
Correct answer: The access will fail with a `NoClassDefFoundError` or similar error.
By default, explicit modules (those on the module path with a `module-info.class`) cannot read from the classpath. The content of the classpath is placed in a special 'unnamed module'. Strong encapsulation in JPMS prevents modules from accessing types in the unnamed module unless permission is explicitly granted via command-line flags like `--add-reads`. Without such flags, the class loading will fail.
Question 3: What exception is thrown when a ConcurrentModificationException occurs?
- It is thrown when a collection is modified while iterating over it with a fail-fast iterator (Correct answer)
- It is thrown when Collections.synchronizedList() detects a race condition
- It is thrown when two threads write to the same collection simultaneously
- 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 4: What does the PL/SQL keyword 'EXCEPTION' handle?
- It handles runtime errors (Correct answer)
- It terminates the program
- 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 5: Which of the following statements about EnumSet is correct?
- EnumSet uses a hash table internally and allows null elements
- EnumSet is implemented as a bit vector and only holds enum constants (Correct answer)
- EnumSet allows mixing of multiple enum types
- EnumSet is synchronized by default
Correct answer: EnumSet is implemented as a bit vector and only holds enum constants
EnumSet is internally represented as a bit vector (RegularEnumSet or JumboEnumSet), making it extremely compact and fast for enum constants.
Question 6: Which SQL function returns the number of months between two dates?
- INTERVAL_MONTHS
- DATEDIFF
- MONTHS_BETWEEN (Correct answer)
- DATE_DIFF
Correct answer: MONTHS_BETWEEN
MONTHS_BETWEEN(date1, date2) returns the number of months between two date values.
Question 7: What is the purpose of Oracle's 'bigfile tablespace' feature?
- Enables compression of all data in the tablespace
- Stores LOB segments separately from table data
- Allows a tablespace to contain thousands of small datafiles
- Allows a single tablespace to contain exactly one very large datafile, simplifying management (Correct answer)
Correct answer: Allows a single tablespace to contain exactly one very large datafile, simplifying management
A bigfile tablespace contains a single datafile that can be up to 128TB, simplifying management by reducing the number of datafiles.
Question 8: What does the 'Cost' column in an Oracle execution plan represent?
- The number of logical reads required
- An optimizer-estimated relative cost based on CPU and I/O estimates compared to a single-block I/O (Correct answer)
- The actual number of rows processed
- Elapsed wall-clock time in milliseconds
Correct answer: An optimizer-estimated relative cost based on CPU and I/O estimates compared to a single-block I/O
The Cost in an Oracle execution plan is a dimensionless optimizer estimate derived from I/O and CPU resource models, not actual time.
Question 9: What is the output of the following code? ```java Deque<Integer> dq = new ArrayDeque<>(); dq.push(1); dq.push(2); dq.push(3); System.out.println(dq.poll()); ```
- 2
- null
- 3 (Correct answer)
- 1
Correct answer: 3
push() adds to the front (stack behavior), so after pushing 1, 2, 3 the front is 3; poll() retrieves from the front, returning 3.
Question 10: Can a subclass method declare more checked exceptions in its throws clause than the overridden parent method?
- No, it can only declare the same or fewer checked exceptions (Correct answer)
- Yes, but only RuntimeExceptions
- Yes, always
- Only if the parent throws Exception
Correct answer: No, it can only declare the same or fewer checked exceptions
An overriding method cannot throw new or broader checked exceptions than those declared by the overridden method.
Question 11: What is a thread starvation scenario in Java?
- A thread is perpetually denied CPU time because higher-priority threads always run first (Correct answer)
- A thread's local cache becomes inconsistent with main memory
- A thread holds a lock indefinitely, preventing progress
- Two threads wait on each other's locks simultaneously
Correct answer: A thread is perpetually denied CPU time because higher-priority threads always run first
Starvation occurs when a thread cannot gain regular CPU access because other threads with higher priority or faster scheduling always preempt it.
Question 12: Which interface must a class implement so its instances can be stored in a TreeSet without a Comparator?
- java.util.Comparator
- java.io.Serializable
- java.lang.Cloneable
- java.lang.Comparable (Correct answer)
Correct answer: java.lang.Comparable
TreeSet requires elements to implement Comparable (specifically compareTo()) for natural ordering unless an explicit Comparator is supplied.
Question 13: What does Collectors.joining(", ") do when used with Stream.collect()?
- Groups elements into a Map by a delimiter
- Concatenates stream elements into a single String separated by ", " (Correct answer)
- Joins two streams together
- Collects elements into a List joined as comma-separated values
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 14: How does Comparator.comparing(Function) work with Stream.sorted()?
- It sorts elements by the value extracted by the key extractor Function (Correct answer)
- It compares Comparator instances
- It returns the maximum element
- It filters elements that don't match the comparison
Correct answer: It sorts elements by the value extracted by the key extractor Function
Comparator.comparing(keyExtractor) creates a Comparator that extracts a sort key from each element; Stream.sorted() then orders elements using that Comparator.
Question 15: In a PL/SQL exception handler, what does SQLCODE return when no exception has occurred?
- 1
- NULL
- 0 (Correct answer)
- -1
Correct answer: 0
SQLCODE returns 0 when no exception has been raised in the current block.
Question 16: What does the following code print? ```java PriorityQueue<Integer> pq = new PriorityQueue<>(); pq.offer(5); pq.offer(1); pq.offer(3); System.out.println(pq.poll()); ```
- 1 (Correct answer)
- Unpredictable
- 3
- 5
Correct answer: 1
PriorityQueue is a min-heap by default, so poll() always retrieves the smallest element, which is 1.
Question 17: Which Oracle tablespace type stores temporary segments used for sort operations and global temporary tables?
- SYSTEM tablespace
- Default permanent tablespace
- UNDO tablespace
- Temporary tablespace (Correct answer)
Correct answer: Temporary tablespace
Temporary tablespaces store temporary segments used for sort operations, hash joins, and global temporary table data.
Question 18: Which command registers a foreign archived log with RMAN after restoring it from another source?
- ADD ARCHIVELOG
- CATALOG ARCHIVELOG (Correct answer)
- CATALOG START WITH
- REGISTER ARCHIVELOG
Correct answer: CATALOG ARCHIVELOG
CATALOG ARCHIVELOG (or CATALOG START WITH for directories) adds existing archived log files to the RMAN repository.
Question 19: What is the purpose of the UNDO tablespace in Oracle Database?
- Store temporary sort segments
- Store data dictionary metadata
- Store redo log entries
- Store rollback information for active transactions (Correct answer)
Correct answer: Store rollback information for active transactions
The UNDO tablespace stores before-image data needed to roll back transactions and provide read consistency.
Question 20: What is the difference between findFirst() and findAny() on a sequential stream?
- On sequential streams they behave identically, always returning the first element (Correct answer)
- findFirst() blocks until the stream is fully consumed
- findFirst() returns the last element, findAny() returns the first
- 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 is the effect of placing a JAR on the classpath (not module path) in a modular application?
- It becomes an automatic module
- It is ignored by the class loader
- It becomes a named module automatically
- It becomes part of the unnamed module (Correct answer)
Correct answer: It becomes part of the unnamed module
All JARs on the classpath are consolidated into a single unnamed module, which has no module-info and can access all exported packages.
Question 22: Which component of Oracle's Program Global Area (PGA) stores bind variable values and the state of a cursor for a specific session?
- Stack space
- Sort area
- Session memory
- Private SQL area (Correct answer)
Correct answer: Private SQL area
The private SQL area within the PGA stores cursor state, bind variable values, and query execution state for each open cursor in a session.
Question 23: Which terminal operation returns true if ALL elements of a stream match a given predicate?
- matchAll(Predicate)
- allMatch(Predicate) (Correct answer)
- anyMatch(Predicate)
- noneMatch(Predicate)
Correct answer: allMatch(Predicate)
Stream.allMatch(Predicate) is a short-circuit terminal operation that returns true only when every element in the stream satisfies the predicate.
Question 24: Which of the following is true about declaring assertions in class static initializers?
- Assertions are illegal in static initializers
- Assertions in static initializers use class-level enable flags
- Assertions in static initializers use system assertions flags (-esa) (Correct answer)
- Static initializers always have assertions enabled
Correct answer: Assertions in static initializers use system assertions flags (-esa)
Assertions in static initializers of system classes are controlled by the -esa (enable system assertions) flag, separate from -ea.
Question 25: What documentation practice is considered essential in Backup, Recovery & Data Guard within the Oracle Certified Professional field?
- Completing all documentation at the end of the workday
- Recording actions, observations, and outcomes in real-time or as close to the event as possible (Correct answer)
- Using shorthand notes that can be expanded later if needed
- Only documenting unusual events or complications
Correct answer: Recording actions, observations, and outcomes in real-time or as close to the event as possible
Real-time or near-real-time documentation in Backup, Recovery & Data Guard ensures accuracy, provides a contemporaneous record, and is considered the gold standard for professional accountability and legal defensibility.
Question 26: Which stream operation is guaranteed to be stateful and may require processing the entire stream before producing output?
- peek()
- sorted() (Correct answer)
- map()
- filter()
Correct answer: sorted()
sorted() is a stateful intermediate operation because it must examine all elements to determine their order before emitting any results.
Question 27: Which of the following is a valid generic method declaration?
- public generic T swap(T a, T b) {}
- public <T> T swap(T a, T b) {} (Correct answer)
- public T swap(T a, T b) {}
- public Object<T> swap(T a, T b) {}
Correct answer: public <T> T swap(T a, T b) {}
A generic method must declare its type parameter inside angle brackets before the return type, as in `<T> T swap(T a, T b)`.
Question 28: What interface must a class implement to be used in a try-with-resources statement?
- Closeable
- Either Closeable or AutoCloseable (Correct answer)
- Serializable
- AutoCloseable
Correct answer: Either Closeable or AutoCloseable
A class can be used in try-with-resources if it implements either AutoCloseable or its subinterface Closeable.
Question 29: What is the purpose of the Block Change Tracking file in Oracle?
- It tracks which archived logs have been applied during recovery
- It stores undo information for flashback queries
- It maps datafile blocks to their SCN values
- It records which blocks have changed since the last backup to speed up incremental backups (Correct answer)
Correct answer: It records which blocks have changed since the last backup to speed up incremental backups
The Block Change Tracking file stores a bitmap of changed blocks, allowing RMAN incremental backups to skip unchanged blocks without scanning entire datafiles.
Question 30: Which Oracle feature automatically manages disk group mirroring, striping, and rebalancing for database files?
- Direct NFS (dNFS)
- Oracle Restart
- Oracle Managed Files (OMF)
- Automatic Storage Management (ASM) (Correct answer)
Correct answer: Automatic Storage Management (ASM)
Oracle ASM provides volume management and file system capabilities for Oracle database files, including automatic striping and mirroring across disks.
Question 31: When performing RMAN tablespace point-in-time recovery (TSPITR), which objects CANNOT be recovered using this method?
- Sequences in the recovered tablespace
- Stored procedures in the recovered tablespace
- Indexes on the recovered tablespace
- Tables with foreign key constraints referencing tables in other tablespaces (Correct answer)
Correct answer: Tables with foreign key constraints referencing tables in other tablespaces
TSPITR cannot automatically handle referential integrity constraints that span tablespaces; tables with cross-tablespace foreign keys require manual intervention.
Question 32: Which of the following correctly uses method references to print each element of a stream?
- stream.map(System.out::println)
- stream.forEach(System.out.println())
- stream.peek(System.out::println).collect()
- stream.forEach(System.out::println) (Correct answer)
Correct answer: stream.forEach(System.out::println)
System.out::println is an instance method reference that matches the Consumer<T> expected by forEach(), making it the correct form.
Question 33: What is the purpose of the Oracle instance?
- It maintains user access control
- It is responsible for backup and recovery
- It stores the physical data files
- It manages the database's processes and memory (Correct answer)
Correct answer: It manages the database's processes and memory
An Oracle instance is a combination of the System Global Area (SGA) and the background processes that access the database files. It acts as the interface between users and the physical database, managing all database operations, memory allocation, and process execution. Without an instance, the database files cannot be accessed or manipulated.
Question 34: Examine the following code snippet: ```java NavigableSet<Integer> set = new TreeSet<>(); set.add(10); set.add(20); set.add(30); set.add(40); System.out.println(set.lower(30)); System.out.println(set.floor(30)); System.out.println(set.higher(30)); ``` What will be the output?
- 20 30 40 (Correct answer)
- null 30 40
- 30 30 40
- 20 20 40
Correct answer: 20 30 40
The `NavigableSet` interface provides methods for finding elements relative to a given value. `lower(E e)` returns the greatest element strictly less than `e`. In this case, `set.lower(30)` returns 20. `floor(E e)` returns the greatest element less than or equal to `e`. So, `set.floor(30)` returns 30. `higher(E e)` returns the least element strictly greater than `e`, so `set.higher(30)` returns 40.
Question 35: What is the result when a variable declared in try-with-resources is referenced after the try block?
- It retains its last assigned value
- Compilation error — scope is limited to the try block (Correct answer)
- It throws IllegalStateException
- It is null after the block
Correct answer: Compilation error — scope is limited to the try block
Variables declared in the resource specification of try-with-resources are scoped to the try block and cannot be accessed outside it.
Question 36: When using RMAN with a recovery catalog, what advantage does it provide over using only the control file?
- Faster backup speeds due to catalog indexing
- Stores backup history beyond the CONTROL_FILE_RECORD_KEEP_TIME limit and supports multiple databases (Correct answer)
- Enables block change tracking across databases
- Allows RMAN to bypass operating system file permissions
Correct answer: Stores backup history beyond the CONTROL_FILE_RECORD_KEEP_TIME limit and supports multiple databases
The recovery catalog retains full backup history indefinitely across all databases, unlike the control file which is limited by CONTROL_FILE_RECORD_KEEP_TIME.
Question 37: What does it mean for a class to be 'immutable' in Java?
- It is declared final and cannot be extended
- It contains only static methods
- Its state cannot be changed after construction (Correct answer)
- It implements the Immutable interface
Correct answer: Its state cannot be changed after construction
An immutable class's state cannot be modified after its object is created — typically achieved with final fields and no setters.
Question 38: Which collector groups stream elements into a Map<Boolean, List<T>>?
- Collectors.counting()
- Collectors.groupingBy(Function)
- Collectors.partitioningBy(Predicate) (Correct answer)
- Collectors.toMap(Function, 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 39: 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")); ```
- An empty Optional
- null
- A NoSuchElementException is thrown
- Not Found (Correct answer)
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 40: Which JVM flag enables assertions for a specific class named `com.example.MyClass`?
- -ea:com.example.MyClass
- -enableassertions:com.example.MyClass
- Both A and B are correct (Correct answer)
- -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 41: Which reflection method is used at runtime to load service provider implementations declared via `provides ... with` in module-info.java?
- Class.forName()
- ClassLoader.getResources()
- ServiceLoader.load() (Correct answer)
- Module.getService()
Correct answer: ServiceLoader.load()
`ServiceLoader.load(ServiceInterface.class)` discovers and instantiates all implementations registered via the module system's `provides` directive.
Question 42: What is the difference between Path.resolve() and Path.relativize() in Java NIO.2?
- They are interchangeable aliases for the same operation
- resolve() works only with absolute paths; relativize() works only with relative paths
- resolve() combines two paths into one; relativize() computes the relative path between two paths (Correct answer)
- resolve() reads the file content; relativize() writes relative content
Correct answer: resolve() combines two paths into one; relativize() computes the relative path between two paths
Path.resolve() appends one path to another to form a combined path, while Path.relativize() computes the relative path needed to navigate from one path to another.
Question 43: Which of the following is a valid and most concise lambda expression for a `java.util.function.Predicate<String>` that tests if a string is empty?
- s -> s.isEmpty()
- () -> "".isEmpty()
- String::isEmpty (Correct answer)
- (String s) -> { return s.isEmpty(); }
Correct answer: String::isEmpty
`String::isEmpty` is a method reference, which is a compact form of a lambda expression used to refer to a method without invoking it. In this case, it refers to the `isEmpty()` method of the `String` class. It is functionally equivalent to the lambda `s -> s.isEmpty()` but is generally preferred for its conciseness and clarity when the lambda simply calls an existing method. The other options are also functionally correct but are not the most concise syntax available.
Question 44: What is the difference between `Executors.newFixedThreadPool(n)` and `Executors.newCachedThreadPool()`?
- Fixed pool creates threads lazily; cached pool pre-creates all threads
- Fixed pool uses a bounded thread count with an unbounded queue; cached pool creates new threads on demand and reuses idle ones (Correct answer)
- Fixed pool terminates idle threads after 60 seconds
- Cached pool has a fixed core size equal to available processors
Correct answer: Fixed pool uses a bounded thread count with an unbounded queue; cached pool creates new threads on demand and reuses idle ones
`newFixedThreadPool` keeps exactly n threads with a `LinkedBlockingQueue`, while `newCachedThreadPool` dynamically creates threads and reuses idle ones with a 60-second keepalive.
Question 45: Which access modifier makes a member visible only within the same package and to subclasses in other packages?
- private
- protected (Correct answer)
- public
- package-private (no modifier)
Correct answer: protected
`protected` grants access within the same package and to subclasses regardless of package.
Question 46: 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", "banana", "apricot", and "cherry", and `count` will be 4.
- 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 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.
Question 47: What happens when you call Iterator.remove() before calling Iterator.next()?
- It throws NoSuchElementException
- It removes the last element of the collection
- It silently does nothing
- 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 48: Which exception class must be the parent when creating a custom checked exception?
- Error
- Throwable directly
- Exception (but not RuntimeException) (Correct answer)
- 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: What is the PRIMARY purpose of continuing education requirements in Backup, Recovery & Data Guard for OCP professionals?
- Networking with other professionals in the field
- Maintaining current knowledge and competency as the field evolves (Correct answer)
- Earning additional credentials for career advancement
- Fulfilling mandatory regulatory requirements only
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 50: What does the Oracle parameter DB_BLOCK_SIZE determine, and when can it be changed?
- The maximum size of a single table; it can be changed with ALTER TABLE
- The size of redo log buffer blocks; it can be changed with ALTER SYSTEM
- The standard block size for the database; it can only be set at database creation (Correct answer)
- The number of blocks read during a full table scan; it can be tuned dynamically
Correct answer: The standard block size for the database; it can only be set at database creation
DB_BLOCK_SIZE sets the standard Oracle data block size for the database and can only be specified at database creation time — it cannot be changed afterward.
Question 51: What is the functional interface type used by Stream.map()?
- Consumer<T>
- UnaryOperator<T>
- Function<T, R> (Correct answer)
- Predicate<T>
Correct answer: Function<T, R>
Stream.map(Function<T,R>) transforms each element of type T into a result of type R using the provided Function.
Question 52: 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
- [0, 0, 0]
- [1, 2, 3] (Correct answer)
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 53: What does Collectors.groupingBy(Function, Collectors.counting()) produce?
- Map<K, Long> (Correct answer)
- Map<K, Optional<Long>>
- Map<K, List<T>>
- Map<K, Integer>
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 54: What is the effect of setting the NO_MERGE hint in an Oracle SQL query containing an inline view?
- Forces a sort-merge join on the inline view result set
- Prevents the optimizer from using any indexes on the inline view columns
- Prevents the optimizer from merging the inline view query into the outer query block (Correct answer)
- Disables parallel execution for the subquery
Correct answer: Prevents the optimizer from merging the inline view query into the outer query block
The NO_MERGE hint prevents view merging, keeping the inline view as a separate query block so its results are materialized before being joined to the outer query.
Question 55: Which terminal operation returns an OptionalDouble representing the average of a DoubleStream?
- average() (Correct answer)
- sum()
- mean()
- reduce()
Correct answer: average()
DoubleStream.average() is a terminal operation that returns OptionalDouble containing the arithmetic mean of all elements.
Question 56: What is the result of calling `getCause()` on an exception that wraps another?
- The original underlying exception (Correct answer)
- The exception message string
- null always
- The outermost exception
Correct answer: The original underlying exception
getCause() returns the Throwable that caused this exception to be thrown, enabling exception chaining.
Question 57: 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()); } } ```
- 10
- The code will not compile because a `finally` block cannot have a `return` statement.
- 30 (Correct answer)
- 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 58: What is the primary purpose of the Oracle 'flashback' technology at the database level?
- To accelerate query performance using cached results
- To mirror redo logs to a standby site
- To compress historical data automatically
- To allow the database to be rewound to a previous point in time without restoring from backup (Correct answer)
Correct answer: To allow the database to be rewound to a previous point in time without restoring from backup
Oracle Flashback Database uses flashback logs to quickly rewind the entire database to a past SCN or timestamp without needing a full RMAN restore.
Question 59: What is printed by the following snippet? ```java Map<String, Integer> m = new HashMap<>(); m.put("a", 1); System.out.println(m.getOrDefault("b", 99)); ```
- 0
- 99 (Correct answer)
- Throws NullPointerException
- null
Correct answer: 99
getOrDefault() returns the mapped value if the key exists, or the provided default (99) if the key is absent.
Question 60: What is the output of the following code? ```java class Parent { String greet() { return "Parent"; } } class Child extends Parent { String greet() { return "Child"; } } Parent p = new Child(); System.out.println(p.greet()); ```
- null
- Parent
- Child (Correct answer)
- Compilation error
Correct answer: Child
Method overriding uses dynamic dispatch — at runtime the JVM calls Child's `greet()` because the actual object is a Child.
Question 61: When Oracle performs a 'log switch', what event is triggered?
- The database shuts down cleanly
- DBWR archives the current redo log to disk
- The control file is recreated
- LGWR begins writing to the next redo log group and a checkpoint may be initiated (Correct answer)
Correct answer: LGWR begins writing to the next redo log group and a checkpoint may be initiated
A log switch occurs when LGWR fills the current redo log group and switches to the next available group, potentially triggering a checkpoint.
Question 62: 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)); ```
- Prints 42
- Compile error: incompatible types (Correct answer)
- ClassCastException at runtime
- 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 63: Which Java class should you use to represent a single point in time as seconds since the Unix epoch?
- ZonedDateTime
- LocalDateTime
- Instant (Correct answer)
- Timestamp
Correct answer: Instant
Instant models a single instantaneous point on the timeline in epoch-seconds and nanosecond adjustment, independent of any time zone.
Question 64: What is the correct way to create an unmodifiable Map with three entries in Java 9+?
- new ImmutableMap<>("a",1,"b",2,"c",3)
- Collections.unmodifiableMap(new HashMap<>(){{put("a",1);}})
- Map.of("a",1,"b",2,"c",3) (Correct answer)
- Map.copyOf(Map.entry("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 65: How can Oracle SQL Developer help with performance tuning?
- By providing network diagnostics
- By automatically rewriting SQL code
- By performing manual backups
- By identifying and analyzing slow-running queries (Correct answer)
Correct answer: By identifying and analyzing slow-running queries
Oracle SQL Developer provides various tools and features that assist with performance tuning, such as the SQL Worksheet, Explain Plan, and SQL Tuning Advisor integration. These features allow developers and DBAs to identify slow-running queries, analyze their execution plans, and receive recommendations for optimization. This helps pinpoint and resolve performance bottlenecks effectively.
Question 66: What is the effect of catching a checked exception that the try block cannot throw?
- It causes a runtime warning
- It is silently ignored at runtime
- It causes a compile-time error (Correct answer)
- It is allowed as defensive programming
Correct answer: It causes a compile-time error
Catching a checked exception that cannot be thrown by the try block results in a compile-time error in Java.
Question 67: Which of the following statements most accurately describes a primary difference between `java.util.concurrent.CyclicBarrier` and `java.util.concurrent.CountDownLatch`?
- 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)
- `CyclicBarrier` is limited to coordinating exactly two threads, while `CountDownLatch` can coordinate any number of threads.
- 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 68: Which collection class is most appropriate for a LIFO (last-in, first-out) stack in modern Java?
- java.util.ArrayDeque (Correct answer)
- java.util.LinkedList used as Queue
- java.util.PriorityQueue
- java.util.Stack
Correct answer: java.util.ArrayDeque
ArrayDeque is recommended over the legacy Stack class for LIFO operations because it is faster and not synchronized.
Question 69: What does `Future.cancel(true)` do to a running task?
- Throws an exception in the task's thread
- Immediately terminates the thread
- Waits for the task to complete then marks it cancelled
- Attempts to interrupt the thread executing the task (Correct answer)
Correct answer: Attempts to interrupt the thread executing the task
Passing `true` to `cancel()` sends an interrupt signal to the thread running the task, but the task must check for interruption to stop.
Question 70: What happens to a tablespace that is taken offline with the NORMAL option before a backup?
- The tablespace is dropped from the backup
- The tablespace datafiles are deleted from disk
- Oracle requires an immediate media recovery
- A checkpoint is issued and the tablespace needs no recovery when brought back online (Correct answer)
Correct answer: A checkpoint is issued and the tablespace needs no recovery when brought back online
OFFLINE NORMAL forces a checkpoint so the datafiles are consistent and no recovery is required when the tablespace is brought back online.
Question 71: What is the result of Optional.empty().orElseGet(() -> "default")?
- "default" (Correct answer)
- null
- 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 72: 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 73: What happens when you call a terminal operation on a stream that has already been consumed?
- IllegalStateException is thrown at runtime (Correct answer)
- A new stream is automatically created
- An empty result is returned
- 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 74: Which Oracle DDL statement would you use to change a column's datatype from VARCHAR2(50) to VARCHAR2(100)?
- CHANGE COLUMN
- ALTER TABLE ... MODIFY (column VARCHAR2(100)) (Correct answer)
- MODIFY COLUMN
- UPDATE COLUMN TYPE
Correct answer: ALTER TABLE ... MODIFY (column VARCHAR2(100))
ALTER TABLE table_name MODIFY (column_name new_datatype) is the Oracle syntax for modifying an existing column's definition.
Question 75: What is the return type of Stream.collect(Collectors.toList())?
- ArrayList<T>
- List<T> (Correct answer)
- Collection<T>
- Optional<List<T>>
Correct answer: List<T>
Collectors.toList() accumulates elements into a List<T>; the specification does not guarantee ArrayList, but the return type in the API is List<T>.
Question 76: Which RMAN feature allows backing up directly to Oracle Cloud Object Storage?
- Oracle Data Pump with cloud export
- RMAN Cloud Module
- RMAN COPY TO CLOUD command
- SBT (System Backup to Tape) channel with OCI library (Correct answer)
Correct answer: SBT (System Backup to Tape) channel with OCI library
RMAN uses SBT (System Backup to Tape) channels configured with the Oracle Cloud Infrastructure library to stream backups to object storage.
Question 77: Which of the following correctly parses the string "2024-06-15" into a LocalDate?
- LocalDate.parse("2024-06-15", DateTimeFormatter.ISO_LOCAL_DATE) only
- LocalDate.of("2024-06-15")
- LocalDate.parse("2024-06-15") only
- Both options parse the string correctly (Correct answer)
Correct answer: Both options parse the string correctly
LocalDate.parse(String) defaults to ISO_LOCAL_DATE format, so both the no-formatter overload and the explicit ISO_LOCAL_DATE formatter parse the same string identically.
Question 78: Which of the following is a valid way to create a parallel stream from a List?
- list.stream().toParallel()
- Stream.parallel(list)
- list.parallelStream() (Correct answer)
- Streams.parallel(list)
Correct answer: list.parallelStream()
Collection.parallelStream() is the standard method to obtain a parallel Stream directly from any Collection implementation.
Question 79: Which SQL clause is used to filter results based on specific conditions?
- ORDER BY
- FROM
- WHERE (Correct answer)
- HAVING
Correct answer: WHERE
The `WHERE` clause in SQL is fundamental for filtering rows returned by a query. It evaluates a specified condition for each row in the table(s) and includes only those rows for which the condition is true. This allows users to retrieve a subset of data that meets specific criteria, making queries more precise.
Question 80: Which `ExecutorService` method submits a `Callable` and returns a `Future` representing the pending result?
- execute(Runnable)
- submit(Callable) (Correct answer)
- schedule(Callable, long, TimeUnit)
- invokeAll(Collection)
Correct answer: submit(Callable)
`submit(Callable)` accepts a `Callable` and returns a `Future<T>` that can be used to retrieve the result.
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