Loading…
Loading…
Topic
Articles and problems tagged OCP Java 21.
Ten exam-style questions on local classes, effectively final captures, anonymous classes extending classes and implementing interfaces, the trailing semicolon, local records, and lambdas versus anonymous classes, with explanations.
Ten exam-style questions on inner classes, the outer.new Inner() syntax, Outer.this, static nested classes, implicitly static nested records, enums and interfaces, modifiers and access between outer and nested classes, with explanations.
Ten exam-style questions on record patterns: deconstruction with instanceof, component count, order and types, run-time matching of nested types, null components, nested patterns, var and generics, and record patterns in switch, with explanations.
Ten exam-style questions on records: generated members, accessors, long, compact and overloaded constructors, transforming parameters, immutability, implementing interfaces and the members a record may or may not declare, with explanations.
Ten exam-style questions on sealed, permits, final, sealed and non-sealed subclasses, omitting permits, nested subclasses, sealed interfaces, package rules and exhaustive switches over sealed types, with explanations.
Ten exam-style questions on simple and complex enums, values(), valueOf(), ordinal(), enums in switch including Java 21 qualified case labels, private constructors, constant-specific bodies, abstract methods and interfaces, with explanations.
Ten exam-style questions on default methods, conflicting defaults and Interface.super, the class-wins rule, static interface methods that aren't inherited, and private and private static helpers, with explanations.
Ten exam-style questions on declaring and implementing interfaces, implicit modifiers, constants, extends versus implements, duplicate abstract methods, instanceof with interfaces and the @Deprecated, @SuppressWarnings and @SafeVarargs annotations, with explanations.
A 20-question mixed review of OCP Java 21 Chapter 6: inheritance and class modifiers, this and super, constructors and constructor chaining, initialization order, final fields, overriding and hiding, abstract classes and immutable objects.
Ten exam-style questions on the immutability recipe, final fields that still leak, defensive copies in constructors and getters, List.copyOf versus unmodifiable views, arrays, and shallowly immutable records, with explanations.
Ten exam-style questions on abstract classes and methods, the first concrete subclass rule, constructors in abstract classes, anonymous subclasses, illegal modifier combinations and abstract syntax traps, with explanations.
Ten exam-style questions on the four overriding rules, covariant return types, checked exceptions in overrides, @Override, redeclared private methods, hidden static methods and fields, and final methods, with explanations.
Ten exam-style questions on class initialization, static and instance initializers, constructor chains, source order, final and static final fields, forward references and overridable calls from constructors, with explanations.
Ten exam-style questions on declaring constructors, when the default constructor exists, private constructors, chaining with this(), calling parent constructors with super(), the inserted super() call, the order constructor bodies run in, and Java 25 flexible constructor bodies, with explanations.
Ten exam-style questions on extends and single inheritance, inherited and non-inherited members, java.lang.Object, final and other class modifiers, top-level class access, and resolving names with this and super, with explanations.
A 20-question mixed review of OCP Java 21 Chapter 5: method declarations, final and effectively final variables, varargs, access modifiers including protected, static members and imports, pass-by-value, autoboxing and overload resolution.
Ten exam-style questions on valid and invalid overloads, the resolution order of exact match, widening, boxing and varargs, most specific methods, reference types and null, float versus double, and ambiguous calls, with explanations.
Ten exam-style questions on pass-by-value for primitives and references, mutating versus reassigning parameters, ignored return values, autoboxing and unboxing rules, widening versus boxing, null unboxing and wrapper equality, with explanations.
Ten exam-style questions on shared static fields, static access through references and null, static versus instance calls, static final constants, static initializers and their order, and static import syntax and name clashes, with explanations.
Ten exam-style questions on private, package, protected and public access: same-class and same-file rules, nested classes, package access across packages, protected access through references, protected constructors and static members, and top-level class modifiers, with explanations.