Study guide

16.1 Standard Annotations: @Override, @FunctionalInterface, @Deprecated, @SuppressWarnings, and @SafeVarargs

Oracle Java SE 17 Developer Certified Professional 1Z0-829

Track your progress as you read

Finished sections get a check mark.

1 Introduction: The 1Z0-829 Exam

About the Java SE 17 Developer (1Z0-829) Exam

2 Chapter 1: Java Fundamentals & Language Basics

1.1 Primitive Types, Literals, Wrapper Classes, and Type Promotion/Casting 1.2 Local Variable Type Inference (`var`) Rules and Scoping 1.3 Operators, Precedence, Evaluation Order, and Short-Circuit Evaluation 1.4 Text Blocks, String Immutability, and StringBuilder APIs

3 Chapter 2: Program Flow & Decision Constructs

2.1 Conditional Branching with if/else and the Ternary Operator 2.2 Switch Statements and Switch Expressions 2.3 Iteration Constructs, Loop Control, and Branching Labels

4 Chapter 3: Object-Oriented Design & Class Mechanics

3.1 Class Declarations, Field/Method Signatures, and Access Modifiers 3.2 Constructors, Overloading, Initialization Order, and Garbage Collection 3.3 Inheritance, Method Overriding, Polymorphism, and `super`/`this` 3.4 Abstract Classes, Static Members, and Object Methods (`equals`, `hashCode`, `toString`)

5 Chapter 4: Advanced OOP: Interfaces, Records & Sealed Types

4.1 Interface Architecture: Default, Static, and Private Methods 4.2 Enumerations: Constants, Constructors, Methods, and Custom Bodies 4.3 Records: Canonical/Compact Constructors, Components, and Immutability 4.4 Sealed Classes and Interfaces: `permits`, Hierarchy Constraints, and Modifiers

6 Chapter 5: Pattern Matching & Nested Types

5.1 Pattern Matching for `instanceof` and Flow Scoping Mechanics 5.2 Nested Types: Member Inner, Static Nested, Local, and Anonymous Classes 5.3 Defensive Programming, Immutability Patterns, and Validation

7 Chapter 6: Generics, Collections & Arrays

6.1 Generic Classes, Interfaces, Methods, and Type Erasure 6.2 Bounded Type Parameters and Wildcards (PECS Rule) 6.3 Collections Framework: List, Set, Queue, and Deque APIs 6.4 The Map Interface, Sorting, Comparable, and Comparator 6.5 Arrays: Declaration, Initialization, Multidimensional Arrays, and the Arrays Utility Class

8 Chapter 7: Functional Programming & Lambda Expressions

7.1 Functional Interfaces and Lambda Syntax Rules 7.2 Standard Functional Interfaces in `java.util.function` 7.3 Method References: Static, Bound, Unbound, and Constructor References

9 Chapter 8: The Stream API

8.1 Stream Lifecycle: Creation, Pipeline Architecture, and Lazy Evaluation 8.2 Intermediate Stream Operations: Filtering, Mapping, Sorting, and Slicing 8.3 Terminal Stream Operations: Reduction, Matching, Finding, and Collecting 8.4 Primitive Streams (`IntStream`, `LongStream`, `DoubleStream`) and Numeric Statistics

10 Chapter 9: Advanced Streams & Collectors

9.1 The Optional Class: Safe Null Handling, Transformation, and Chaining 9.2 The Collectors API: Downstream Reductions, Grouping, and Partitioning 9.3 Parallel Streams: Fork/Join Pool, Spliterators, and Concurrency Pitfalls

11 Chapter 10: Exception Handling

10.1 The Java Exception Hierarchy: Checked vs. Unchecked Exceptions and Errors 10.2 Exception Constructs: `try-catch-finally`, Multi-Catch, and Rethrowing 10.3 Try-With-Resources, `AutoCloseable`, Suppressed Exceptions, and Custom Exceptions

12 Chapter 11: Date/Time API & Localization

11.1 Date and Time Core Types: `LocalDate`, `LocalTime`, `LocalDateTime` 11.2 Timestamps, Intervals, and Durations: `Instant`, `Period`, and `Duration` 11.3 Time Zones, Daylight Saving Time (DST) Offsets, and `ZonedDateTime` 11.4 Internationalization and Localization: `Locale`, `ResourceBundle`, and Formatters 11.5 Formatting and Parsing Messages, Numbers, Percentages, and Localized Dates

13 Chapter 12: Java Platform Module System (JPMS)

12.1 Module Architecture, `module-info.java`, and Module Paths 12.2 Module Directives: `requires`, `requires transitive`, `exports`, and Qualified Exports 12.3 Reflection, Deep Encapsulation, `opens`, and Open Modules 12.4 Services in JPMS (`uses`, `provides...with`), Migration Paths, and Tooling (`jlink`, `jdeps`) 12.5 Compiling and Packaging Code: Non-Modular JARs, Modular JARs, and Migration Strategies

14 Chapter 13: Concurrency & Multithreading

13.1 Thread Fundamentals, `Runnable`, `Callable`, and Thread Lifecycle 13.2 Memory Visibility, `volatile`, Intrinsic Locks, and Synchronization 13.3 The Concurrency Framework: `ExecutorService`, Thread Pools, and `Future` 13.4 Concurrent Collections, Atomic Variables, Explicit Locks, and `CompletableFuture`

15 Chapter 14: Java I/O and NIO.2

14.1 Classical I/O: Byte and Character Streams, Readers, Writers, and Buffering 14.2 Object Serialization, `Serializable`, `transient`, and `serialVersionUID` 14.3 NIO.2 Architecture: `Path`, `Paths`, and Basic `Files` Operations 14.4 Advanced NIO.2: Directory Walking, Streams (`Files.lines`, `walk`), and `WatchService`

16 Chapter 15: Accessing Databases with JDBC

15.1 JDBC Architecture, Drivers, `DriverManager`, and `DataSource` Connections 15.2 SQL Execution: `Statement`, `PreparedStatement`, and `CallableStatement` 15.3 `ResultSet` Navigation, Data Types, and Transaction Management (Commit, Rollback, Savepoints)

17 Chapter 16: Annotations & the Java Logging API

16.1 Standard Annotations: @Override, @FunctionalInterface, @Deprecated, @SuppressWarnings, and @SafeVarargs 16.2 Java Logging API Basics: Logger, Levels, Handlers, and Configuration

16.1 Standard Annotations: @Override, @FunctionalInterface, @Deprecated, @SuppressWarnings, and @SafeVarargs

Key Takeaways Explain This Topic AI

@Override makes the compiler reject a method that does not override a supertype method, catching mistakes such as equals(Employee).

@FunctionalInterface fails compilation unless the interface has exactly one abstract method, ignoring default, static, private, and public Object methods.

@Deprecated has the since and forRemoval elements, and forRemoval = true triggers removal warnings that @SuppressWarnings("deprecation") does not silence.

@SuppressWarnings requires a value such as "unchecked", "rawtypes", "deprecation", or "removal", and unrecognized names are ignored.

@SafeVarargs is legal only on varargs constructors and on static, final, or private methods, so it fails on a non-final public instance method.

Last updated: October 2026

16.1 Standard Annotations: @Override , @FunctionalInterface , @Deprecated , @SuppressWarnings , and @SafeVarargs

Oracle lists annotations among the skills candidates are "also expected" to have, naming five built-in annotations. Each one changes what the compiler checks or reports, so exam questions ask whether code compiles and which warnings appear.

Annotation Syntax in One Minute

An annotation is metadata written with @ before a declaration (class, method, field, parameter, local variable) or a type use. Annotations can have elements : @Override // marker annotation: no elements

  • @SuppressWarnings("unchecked") // single element named value: shorthand form
  • @SuppressWarnings(value = {"unchecked", "rawtypes"}) // array value in braces
  • @Deprecated(since = "2.0", forRemoval = true) // several named elements

The value = part can be omitted only when the element is named value and it is the only element supplied. Custom annotations are declared with @interface , but the exam focuses on using the standard ones in java.lang , which need no import.

@Override : Ask the Compiler to Verify an Override

@Override makes the compiler confirm that a method overrides or implements a supertype method. If it does not, compilation fails with method does not override or implement a method from a supertype . class Employee {

  • int id;
  • @Override
  • public boolean equals(Employee other) { return id == other.id; } // COMPILE ERROR: this is an overload
  • }

The annotation catches the classic equals(Employee) overload mistake from 3.4. It is also legal on methods that implement interface methods. It is illegal on static methods , because static methods are hidden, not overridden: javac reports static methods cannot be annotated with @Override .

@FunctionalInterface : Lock In the Single Abstract Method

@FunctionalInterface asks the compiler to verify that an interface has exactly one abstract method (default, static, private, and public Object methods do not count; see 7.1). An annotated interface with two abstract methods fails with Unexpected @FunctionalInterface annotation . The annotation is optional: an interface with one abstract method is functional either way, but the annotation stops a later edit from silently breaking every lambda that targets it.

@Deprecated : Mark APIs That Should No Longer Be Used

@Deprecated marks a type, method, field, or constructor as discouraged. Since Java 9 it has two optional elements:

  • Element Type Meaning
  • since String The version in which the API was deprecated
  • forRemoval boolean (default false ) true means the API is scheduled to be deleted

Using a deprecated API compiles, but javac reports a warning. An ordinary deprecation produces a deprecation note or warning, while forRemoval = true produces a stronger removal warning even without -Xlint , for example [removal] Integer(int) in Integer has been deprecated and marked for removal . Do not confuse the annotation with the Javadoc tag @deprecated (lowercase), which only documents the reason.

@SuppressWarnings : Silence Specific Compiler Warnings

@SuppressWarnings takes one or more warning names and suppresses those warnings inside the annotated declaration:

  • Value Suppresses
  • "unchecked" Unchecked generic operations, such as adding to a raw List
  • "rawtypes" Use of raw types such as List instead of List<String>
  • "deprecation" Warnings for ordinary deprecated APIs
  • "removal" Warnings for APIs deprecated with forRemoval = true

Rules to remember:

The value element has no default, so @SuppressWarnings with no argument does not compile.

"deprecation" does not suppress removal warnings; code that calls a forRemoval = true method needs @SuppressWarnings("removal") .

javac ignores names it does not recognize, so a misspelled value compiles but suppresses nothing.

Put the annotation on the narrowest declaration possible, such as a single local variable, rather than a whole class.

@SafeVarargs : Promise That a Generic Varargs Method Is Safe

A varargs parameter of a generic type, such as T... items , creates a generic array, so javac warns about possible heap pollution at the declaration and at every call site. @SafeVarargs is the method author's promise that the method does not store or expose the array unsafely, and it suppresses those warnings.

The annotation is legal only on methods that cannot be overridden and that actually have a varargs parameter:

Declaration @SafeVarargs allowed?

  • Constructor Yes
  • static method Yes
  • final instance method Yes
  • private instance method (Java 9+) Yes

Non-final, non-private instance method No: Invalid SafeVarargs annotation. Instance method ... is neither final nor private.

Method without a varargs parameter No: Invalid SafeVarargs annotation. Method ... is not a varargs method. public class Lists {

  • @SafeVarargs
  • static <T> List<T> listOf(T... items) { // legal: static
  • return Arrays.asList(items);
  • }
  • // @SafeVarargs
  • // public <T> void addAll(T... items) {} // COMPILE ERROR: neither final nor private
  • }
  • Quick Comparison

Annotation Checked by the compiler Typical exam question

@Override Method really overrides Does equals(Employee) with @Override compile?

@FunctionalInterface Exactly one abstract method Is an interface with toString() plus one method functional?

@Deprecated Generates warnings for callers What do since and forRemoval mean?

@SuppressWarnings Silences named warnings Which value silences a removal warning?

@SafeVarargs Placement rules Which method declarations may use it?

Declaring and Applying a Custom Annotation

You will mostly apply the built-in annotations, but reading a custom declaration helps with element-syntax questions: import java.lang.annotation.*;

  • @Retention(RetentionPolicy.RUNTIME) // keep it in the class file and visible to reflection
  • @Target({ElementType.METHOD, ElementType.TYPE}) // allowed on methods and types only
  • public @interface Audit {
  • String value(); // required: no default
  • int priority() default 1; // optional
  • String[] tags() default {}; // optional array element
  • }
  • @Audit("orders") // value shorthand
  • class OrderService {
  • @Audit(value = "pay", priority = 3, tags = {"pci", "money"})
  • void pay() {}
  • @Audit(value = "refund", tags = "single") // one array element may omit braces
  • void refund() {}
  • }

Compile-time rules for annotation elements:

An element without a default must be supplied: @Audit(priority = 2) fails with annotation @Audit is missing a default value for the element 'value' .

Element types are limited to primitives, String , Class , enums, other annotations, and one-dimensional arrays of those; an Object element fails with invalid type for annotation type element .

Default values must be compile-time constants and can never be null .

Applying an annotation where its @Target does not allow it, such as @Audit on a local variable here, fails with annotation type not applicable to this kind of declaration .

@Retention(RetentionPolicy.RUNTIME) is required if code reads the annotation with reflection, as in OrderService.class.getAnnotation(Audit.class).value() , which returns "orders" .