OCP 17 Exam - chapter 14 notes - I/O
Streams byte streams are called *InputStream/*OutputStream, where character streams are *Reader/*Writer exceptions are PrintWriter and PrintStream exam my trick us by w...
Streams byte streams are called *InputStream/*OutputStream, where character streams are *Reader/*Writer exceptions are PrintWriter and PrintStream exam my trick us by w...
Executors be aware whether Executors.newSingleThreadExecutor is used, because running on single thread automatically synchronizes executions, so result will be always consistent (Q.22) ...
Note: Java Platform Module System was introduced in JDK 9 in project Jigsaw. In Java 25 modules would be available through imports like regular classes. Running and packaging simple module Folde...
Let’s consider the following example: var list = List.of(1); var first1 = list.stream().findFirst(); var first2 = list.getFirst(); if (Objects.equals(first1, first2)) { // compiles, just warning i...
try-with-resources can be used only with classes that implement AutoCloseable (also java.io.Closeable which extends AutoCloseable) two or more resources can be defined in one try...
Streams fundamentals “Streams are evaluated lazily, which means intermediate operations are not executed until a terminal operation is invoked.” var ints = new ArrayList<Integer>(); ...
be aware of removing or adding elements to an immutable list (List.of) as it will throw UnsupportedOperationException (review Q.2) how to properly define a collection: // HashSet...
exam may trick us by asking about functional interface that doesn’t exist, e.g. IntegerSupplier instead IntSupplier (review Q.9) or we can be tricked by lambda that doesn’t compile (review Q.1...
Sealed classes and interfaces sealed classes allow us to implement “enum” on class level, so it can be used in switch statement: Sealed v = new Chapter7_SealedClasses().new MyClass(); ...
Interfaces abstract is implicit in interface - automatically added by compiler public abstract interface AbstractIsImplicitInInterface { // abstract is implicit (added by compiler) ...