OCP 17 Exam - chapter 10 notes
Streams fundamentals “Streams are evaluated lazily, which means intermediate operations are not executed until a terminal operation is invoked.” var ints = new ArrayList<Integer>(); ...
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) ...
my protip: always start reading code from main method Inheritance synonyms of subtype when working with classes: subclass, child class synonyms of supertype when working with c...
access modifiers (public, protected, …) and optional modifiers (final, static) can be in any order, but must be before return type void public method() { } // DOES NOT COMPILE: invalid method d...
be aware that exam want to trick us on concatenation of String and numbers, e.g. prints 66 int five = 5; String six = "6"; System.out.println(1 + five + six); String#substr...
“watch indentation and braces”, e.g. in the following example count is always incremented if (count < 2) System.out.println("Good day"); count++; “pattern matching was introduced to ...
unary = 1 param, binary = 2 params, ternary = 3 params numeric promotions rules: always to larger data type, e.g. short -> int integral type is promoted to floating point if u...