Loading…
Loading…
Language
Articles and problems tagged Java.
The java.lang.Math methods on the OCP Java 21 exam with their exact return types: min, max, round, ceil, floor, pow, random, plus abs, sqrt, Java 21's clamp, floorDiv/floorMod and exact arithmetic, and BigInteger and BigDecimal for big or exact numbers.
Comparing Java arrays with Arrays.equals, Arrays.compare and Arrays.mismatch and their ordering rules, varargs parameters used as arrays, and arrays of arrays: declarations, rectangular and jagged creation, nested loops, deepToString and deepEquals.
Java arrays for the OCP 21 exam: legal and illegal declarations, default values, initializers, arrays of references, covariance and ArrayStoreException, length and index bounds, Arrays.toString, sort, binarySearch return values, fill and copyOf.
When == is true for Java strings and when it isn't: the string pool, compile-time constants and final variables, runtime concatenation, new String, intern(), equals versus == for String, StringBuilder, arrays and records, and why real code should always use equals.
StringBuilder for the OCP Java 21 exam: why it exists, how chaining returns the same object, the three constructors and the char-capacity trap, append, insert, delete, deleteCharAt, replace, reverse, setLength, Java 21's repeat, index rules, and equality.
The String methods tested on the OCP Java 21 exam: length, charAt, code points, substring boundaries, indexOf with Java 21 range overloads, equals and compareTo, startsWith/contains, replace, strip versus trim, indent and stripIndent, isBlank, format and formatted, and method chaining.
How Java creates String objects (literals, new, text blocks, valueOf), the three rules of + for concatenation versus addition, char arithmetic traps, null in concatenation, += on strings, and why String immutability means methods return new objects.
The OCP Java 21 rules for branching: labels on statements, break and continue with and without a label, break inside a switch inside a loop, return as a way out of nested loops, and the compiler's unreachable-code and missing-return checks.
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.
The Java 21 pattern switch for the OCP exam: type patterns on any reference type, when guards, dominance and branch order, exhaustive statements, case null and case null, default, record patterns, and sealed types without a default.
The OCP Java 21 rules for switch: allowed selector types, compile-time constant case values, colon versus arrow labels, fall-through and break, switch expressions with consistent result types, semicolons, yield, exhaustiveness and qualified enum constants.
Decision-making for the OCP Java 21 exam: statements and blocks, if, else if and else, braces versus indentation, the dangling else, pattern matching with instanceof, pattern variables, conditions after &&, null handling, supported types and flow scoping.
The comparison and decision operators for the OCP Java 21 exam: == and != on primitives and references, relational operators, instanceof and its compile-time checks, & | ^ as logical and bitwise operators, short-circuit && and ||, and the ternary operator's evaluation and result types.
The OCP Java 21 rules for arithmetic: integer division and modulus, division by zero, the four numeric promotion rules, widening and narrowing casts, overflow, constant expressions, compound assignment's hidden cast and the value of an assignment.
The OCP Java 21 rules for operators: unary, binary and ternary operators, the full precedence ladder with associativity, left-to-right operand evaluation, logical and bitwise complement, negation, and the prefix and postfix increment and decrement operators.
Scope and object lifetime for the OCP Java 21 exam: block scope for locals, parameters, loop variables, fields and static variables, shadowing and redeclaration rules, when objects become eligible for garbage collection, System.gc(), and why finalize() is obsolete.
Variable rules for the OCP Java 21 exam: legal identifiers and reserved words, declaring several variables in one statement, final locals, definite assignment, default values for fields, method parameters, every rule of var, and Java 22's unnamed variables.
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 objects are created for the OCP Java 21 exam: new and constructors, the default constructor, methods that only look like constructors, reading and writing fields, instance initializer blocks, illegal forward references, the order of initialization and Java 25 flexible constructor bodies.
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.