🔸 TL;DR ✅
▪️ A JAX-RS REST resource is typically a plain Java class (POJO).
▪️ It becomes a resource by adding @Path and HTTP method annotations.
🔸 CONTEXT (OCP JAVA / JAX-RS)
JAX-RS (Jakarta REST) exposes HTTP endpoints using resource classes.
🔸 TRY THIS QUESTION
In JAX-RS, which statement is correct about how a REST “resource” class is implemented?
▪️ A) The resource class must extend Application
▪️ B) The resource class can be a stateful EJB
▪️ C) The resource class can be a simple POJO (a normal Java class)
▪️ D) The resource class must not be final
✅ Your answer? Don’t scroll too fast 👇
🔸 ANSWER & EXPLANATION ✅
▪️ C) The resource class can be a simple POJO.
In JAX-RS, a resource is usually just a normal Java class.
It becomes a REST endpoint when you annotate it, for example:
@Path on the class (or on methods)
HTTP method annotations like @GET, @POST, etc.
➡️ No need to extend Application. That class is for configuring the JAX-RS app, not for implementing resources.
🔸 QUICK CLARIFICATIONS (WHY OTHERS ARE TRICKY)
▪️ A is false → Application is for bootstrapping/config, not required for resource classes.
▪️ B is misleading → resources are commonly POJOs; some runtimes integrate with EJB/CDI, but the core rule tested here is “resource = POJO + annotations”.
▪️ D is not a rule → being final is not a universal prohibition in the spec (though some frameworks/proxying features may prefer non-final in practice).
🔸 TAKEAWAYS 🧠
▪️ Think: “JAX-RS = annotations turn a normal class into an HTTP endpoint.”
▪️ Don’t confuse application configuration (Application) with resource implementation (POJO).
#Java #OCP #JAXRS #JakartaEE #RESTAPI #BackendDevelopment #JavaCertification #EnterpriseJava #SoftwareEngineering #APIDesign
Go further with Java certification:
Java👇
Spring👇
SpringBook👇
JavaBook👇