300+ TOP RESTful JAVA Web Services Interview Questions [UPDATED]

  1. 1. In Which Scenarios Restful Web Services Are Preferred Over Soap Ones?

    RESTful Web Services are preferred when: 

    a) The Web Services are completely stateless. 
    b) When data can be cached to improve performance. 
    c) Schema of data can be agreed between service consumer and service provider. 
    d) Bandwidth is limited. 

  2. 2. How Do You Refer Or Identify Resources In Rest Design Idiom?

    Resources are identified by their unique URLs. 


  3. Web Service Testing Interview Questions

  4. 3. Is Rest Stateless Or Stateful Client-server Architecture?

    REST is stateless client-server architecture. 

  5. 4. Name The Java Api That Is Used For Building And Deploying Restful Web Services?

    • JAVA API for XML Web Services (JAX-WS) and 
    • JAVA API for XML RESTful Web Services (JAX-RS). 

  6. Web Service Testing Tutorial

  7. 5. How Web Service Interface For Restful Web Services Are Described?

    There is no formal way of describing the Web Service interfaces. To overcome this, service producer and service consumer agree on schemas that describe the data being exchanged. 


  8. Web Services Interview Questions

  9. 6. Name Few Of The Jax-rs Implementations?

    Jersey, RESTEasy, Restlet are to name a few. 

  10. 7. If I Plan To Use The Jersey Distribution For Restful Web Services, Do I Need To Download It?

    Yes. But if you are using NetBeans IDE 6.0, downloading is not required. 


  11. Web Services Tutorial
    Core Java Interview Questions

  12. 8. How Are Resources Addressed?

    Each resource is uniquely addressable using a universal syntax for use in hypermedia links. 

  13. 9. In Restful Architecture, What Represents The Application State And Functionality?

    Uniquely Addressable Resources represent the application state and functionality. 


  14. Java-Springs Interview Questions

  15. 10. What Is Shared Between Restful Resource That Is Used For Transfer Of State Between Client And Resource?

    A uniform interface is shared between resources that comprises of a set of well‐defined operations, content types and optionally supporting code‐on‐demand. 


  16. Core Java Tutorial

  17. 11. How Do You Annotate A Method To Respond To Http Get Requests?

    javax.ws.rs.Get annotation specifies that the annotated method will serve HTTP Get request. 


  18. CSS Interview Questions

  19. 12. Name The Most Commonly Http Methods Used In Designing Restful Services?

    PUT, GET, POST, DELETE.


  20. Web Service Testing Interview Questions

  21. 13. Define One-to-one Mapping Between Http Methods And Crud Operations?

    PUT maps to Create, GET maps to Retrieve, POST maps to Update, DELETE maps to Delete. 


  22. Java-Springs Tutorial

  23. 14. What Are Idempotent Methods?

    A method is said to be idempotent if repeated calls to it does not cause duplicates. 

  24. 15. In Order To Answer Http Put Requests, How Will You Annotate Your Resource Methods?

    The @PUT annotation is used to answer HTTP PUT requests. 


  25. Java Abstraction Interview Questions

  26. 16. Why Put Methods Is Idempotent?

    PUT is used to create a resource and repeating the operation should never create another copy of the resource. 


  27. CSS Tutorial

  28. 17. What Is The Purpose Of Javax.ws.rs.httpmethod?

    HttpMethod annotation is used to associate the name of a HTTP method with an annotation. 


  29. Restful web service Interview Questions

  30. 18. List Resource Method Designator Annotations?

    @GET, @PUT, @POST, @DELETE 


  31. Web Services Interview Questions

  32. 19. Define Root Resource Class?

    Root resource class is basically a POJO (Plain Old JAVA Objects) that is annotated with @Path and has at least one method annotated with @Path or have at least a single resource method. 


  33. Restful web service Tutorial

  34. 20. Define Resource Method?

    Method of a resource class that is annotated with resource method designator annotation is called Resource Method. 


  35. Amazon Web Services (AWS) Interview Questions

  36. 21. How To You Specify Relative Path Of A Resource In Restful Web Service?

    The @Path annotation is used to specify relative URI path. 

    e.g. 

    @Path(“/test”) 

  37. 22. How Can You Embed Variables In The Uri?

    Variables can be embedded within the URI syntax (called URI path template). The variables are substituted at runtime. 

    @Path(“/test/{username}”) 


  38. Spring MVC Framework Tutorial

  39. 23. How Embedded Variables Are Represented In The Uri Syntax?

    Embedded variables are denoted by curly braces. 


  40. Spring MVC Framework Interview Questions

  41. 24. How Can You Obtain The Value Of A Method Parameter In Restful Resource Method?

    @PathParam can be used on method parameter of a resource method to obtain the value for a method parameter. 

    e.g. 

    @GET 
    @Produces(“text/plain”) 
    public String getWelcomeMsg(@PathParam(“username”) String userName) { 
    … 


  42. Core Java Interview Questions

  43. 25. How Can You Define A Regular Expression For A Variable Say Username?

    @Path(“users/{username: [a-zA-Z][a-zA-Z_0-9]*}”) 

  44. 26. What Happens If Regular Expression Of A Uri Embedded Variable Is Not Matched?

    A 404 (Not Found) response will occur. 


  45. Soap Web Services Interview Questions

  46. 27. Will The Following Direct To The Same Resource?
    @path(“/test/”) 
    @path(“/test”) 

    Yes. By default, both should point to the same resource, although Jersey has arection mechanism that is disabled by default. 


  47. Java-Springs Interview Questions

  48. 28. Explain How To Specify Mime Media Types Of A Resource That Is Sent Back To The Client?

    @Produces annotation is used for this purpose..

     e.g. 

    @Produces(“text/plain”) 

  49. 29. Is It True That @produces Can Only Be Applied At Method Level?

    False. It can be applied at both the class and method levels. 

  50. 30. Can @produces Annotation Be Overridden In A Restless Resource? Give Example?

    Yes. In the following example, the default MIME type is set as text/plain but doGetAsHtml method overrides it to text/html. 

    @Path(“/testResource”) 
    @Produces(“text/plain”) 
    public class TestResource { 
    @GET 
    public String doGetAsPlainText() { 
    … 

     
    @GET 
    @Produces(“text/html”) 
    public String doGetAsHtml() { 
    … 

  51. 31. How Can You Declare More Than One Media Type In The Same @produces Declaration?

    @Produces({“application/plain”,”application/xml”, “application/json”}) 

  52. 32. Assume That There Is A Resource Class Capable Of Producing More Than One Mime Media Type For Get. How Will Be The Response Method Chosen?

    Resource method is chosen depending on the most acceptable media type as declared by the client in the request header. 

    e.g. 

    Accept: text/plain. 

  53. 33. How Will You Specify The Mime Media Types Of Representations A Restful Resource Can Use?

    @Consumes annotation is to be used. 


  54. CSS Interview Questions

  55. 34. Write A Method That Is Triggered On Post Request And Takes Text/plain As Input?

    @POST 
    @Consumes(“text/plain”) 
    public void postMessage(String message) { 
    … 

  56. 35. At Which Levels, @consumes Can Be Applied?

    @Consumes can be applied at both the class and method levels. 

  57. 36. Give An Example Of Declaring More Than One Media Type In @consumes Declaration?

    @POST 
    @Consumes({“application/plain”,”application/xml”}) 
    public void postMessage(String message) { 
    … 


  58. Java Abstraction Interview Questions

  59. 37. Can Restful Web Services Support Multiple Types Of Response (mime) Formats?

    RESTful Web Services, by confirming to HTTP, does support multiple types of response (MIME) formats e.g. XML, JSON, PLAIN etc.