Loading…
Loading…
Topic
Articles and problems tagged Object-Oriented Programming.
Thread safety for the OCP 21 exam: why ++ loses updates, what volatile does and doesn't do, AtomicInteger and the other atomic classes, synchronized blocks and methods, which object is the lock, reentrancy and the BLOCKED state.
The exception classes the OCP 21 exam expects you to recognize: ArithmeticException, ArrayIndexOutOfBounds, ClassCastException, NullPointerException, IllegalArgument and NumberFormat, IOException and FileNotFound, ParseException, and Errors like StackOverflowError and ExceptionInInitializerError.
Generics for the OCP 21 exam: declaring generic classes, interfaces and records, type parameter naming, type erasure and its limits, overloading and overriding with generic types, generic methods and explicit type arguments, shadowed type parameters, and bounded type parameters.
Polymorphism for the OCP 21 exam: object type versus reference type, implicit upcasts and explicit downcasts, ClassCastException, casts the compiler rejects (including final, record and sealed types), instanceof patterns, virtual method calls, and hidden fields and static methods.
Local and anonymous classes for the OCP 21 exam: classes inside methods, capturing effectively final locals, outer-instance access, anonymous subclasses and implementations, the trailing semicolon, local records, lambdas versus anonymous classes, and choosing a nested type.
Member-level nested classes for the OCP 21 exam: the four kinds of nested class, inner classes and the outer.new Inner() syntax, Outer.this for shadowed members, static nested classes, nested records, enums and interfaces that are implicitly static, modifiers and generated class files.
Sealed classes and interfaces for the OCP 21 exam: sealed and permits, the final, sealed or non-sealed rule for direct subclasses, same package or module, when permits can be omitted, nested subclasses, sealed interfaces, and exhaustive pattern-matching switches.
Java interfaces for the OCP 21 exam: declaring and implementing them, implicit modifiers on constants and abstract methods, extending multiple interfaces, duplicate abstract methods, class versus interface keywords, plus the @Deprecated, @SuppressWarnings and @SafeVarargs annotations.
Java abstract classes for the OCP 21 exam: declaring abstract classes and methods, the first concrete subclass rule, constructors in abstract classes, anonymous subclasses, illegal modifier combinations (abstract with final, private or static) and the syntax traps the exam loves.
Inheritance basics for the OCP Java 21 exam: extends and single inheritance, java.lang.Object as the root of every class, which members a subclass inherits, final and other class modifiers, top-level class access, and how this and super resolve fields and methods.
The OCP Java 21 rules for loops: while versus do/while, the three optional parts of a for loop, multiple loop variables, loop variable scope, for-each over arrays and Iterable, nested loops, infinite loops and the loop conditions the compiler rejects.
Java's data types for the OCP 21 exam: the eight primitives and their ranges, numeric literals in four bases, underscore rules, primitives versus references, wrapper classes with valueOf and parseXxx, and text blocks with incidental whitespace and escapes.
How Java packages and imports work for the OCP 21 exam: wildcards, java.lang, redundant imports, Date naming conflicts, fully qualified names, javac -d, the three class path options, JAR files, element order in a file and Java 25 module imports.
The OCP Java 21 basics: what the JDK, javac, java and the JVM do, how a class and a source file are structured, the three comment styles, every legal form of main(), command-line arguments, single-file launching and Java 25's compact source files.
Implementing your own ClassLoader by overriding findClass, an integrity-checking loader that rejects tampered class files, child-first loading, parallel-capable loaders and resources, and what the bytecode verifier checks, shown with deliberately broken class files built with the ClassFile API.
How the JVM finds and prepares classes: loading, linking and initialization, the bootstrap, platform and application loaders, parent-first delegation, plugin loaders, class loaders as namespaces, the context class loader, and tools for watching it all happen.
Externalizing user-visible text with ResourceBundle: naming conventions, candidate and default-locale fallback, parent chains, UTF-8 property files, ListResourceBundle classes, ResourceBundle.Control, caching and modules, with a complete localized example.
The java.util.regex pattern language: literals and metacharacters, character classes with ranges, negation and intersection, \d \w \s and Unicode \p{...} classes, greedy, reluctant and possessive quantifiers, groups and back-references, boundaries, lookaround, and escaping.
Read a Java serialization stream byte by byte: the AC ED magic number, TC_ type codes, class descriptors with serialVersionUID fingerprints and flags, field type codes, object handles and back-references, null markers, block data, and what ObjectStreamClass reports.
Learn what reflection can reveal about Java generics despite erasure: the generic Class<T> class, matching Class<T> parameters, the Type interface with TypeVariable, WildcardType, ParameterizedType and GenericArrayType, and type literals (super type tokens) for generic types.