Subjects

All subjects Django Java Python React Spring Boot JavaScript PHP
Sign Up Free
Java 9 questions

Java Annotations, Reflection & Design Patterns

Use reflection to inspect classes at runtime. Learn built-in annotations, custom metadata, and common structural design patterns.

More Java
Interview questions 1–9 of 9
1

What are annotations in Java and what are some commonly used built-in annotations?

Annotations are metadata attached to code (classes, methods, fields) that don't directly affect program logic...

Read answer →
2

How do you create a custom annotation in Java?

Custom annotations are defined using @interface, combined with meta-annotations (@Retention, @Target) that con...

Read answer →
3

What is the Reflection API in Java and what can you do with it?

Reflection lets a program inspect and manipulate classes, methods, fields, and constructors at RUNTIME, even w...

Read answer →
4

What is the Singleton design pattern and how do you implement it thread-safely in Java?

Singleton ensures a class has exactly ONE instance and provides a global access point to it - commonly used fo...

Read answer →
5

What is the Factory design pattern and when should you use it?

The Factory pattern encapsulates object creation logic in a dedicated method or class, so client code depends...

Read answer →
6

What is the Builder design pattern and how does it help with complex object construction?

The Builder pattern constructs complex objects step by step, avoiding constructors with many parameters (teles...

Read answer →
7

What is the Observer design pattern and where is it used in Java?

The Observer pattern defines a one-to-many dependency where multiple 'observer' objects are notified automatic...

Read answer →
8

What is dependency injection and how does it relate to design patterns?

Dependency injection (DI) is a technique where an object's dependencies are provided from outside rather than...

Read answer →
9

What is the difference between the Comparable pattern and the Strategy design pattern?

Comparable defines a class's single natural ordering baked into the class itself, while the Strategy pattern l...

Read answer →