-
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. How Do You Refer Or Identify Resources In Rest Design Idiom?
Resources are identified by their unique URLs.
-
3. Is Rest Stateless Or Stateful Client-server Architecture?
REST is stateless client-server architecture.
-
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).
-
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.
-
6. Name Few Of The Jax-rs Implementations?
Jersey, RESTEasy, Restlet are to name a few.
-
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.
-
8. How Are Resources Addressed?
Each resource is uniquely addressable using a universal syntax for use in hypermedia links.
-
9. In Restful Architecture, What Represents The Application State And Functionality?
Uniquely Addressable Resources represent the application state and functionality.
-
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.
-
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.
-
12. Name The Most Commonly Http Methods Used In Designing Restful Services?
PUT, GET, POST, DELETE.
-
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.
-
14. What Are Idempotent Methods?
A method is said to be idempotent if repeated calls to it does not cause duplicates.
-
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.
-
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.
-
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.
-
18. List Resource Method Designator Annotations?
@GET, @PUT, @POST, @DELETE
-
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.
-
20. Define Resource Method?
Method of a resource class that is annotated with resource method designator annotation is called Resource Method.
-
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”)
-
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}”)
-
23. How Embedded Variables Are Represented In The Uri Syntax?
Embedded variables are denoted by curly braces.
-
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) {
…
} -
25. How Can You Define A Regular Expression For A Variable Say Username?
@Path(“users/{username: [a-zA-Z][a-zA-Z_0-9]*}”)
-
26. What Happens If Regular Expression Of A Uri Embedded Variable Is Not Matched?
A 404 (Not Found) response will occur.
-
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.
-
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”)
-
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.
-
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() {
…
}
} -
31. How Can You Declare More Than One Media Type In The Same @produces Declaration?
@Produces({“application/plain”,”application/xml”, “application/json”})
-
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.
-
33. How Will You Specify The Mime Media Types Of Representations A Restful Resource Can Use?
@Consumes annotation is to be used.
-
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) {
…
} -
35. At Which Levels, @consumes Can Be Applied?
@Consumes can be applied at both the class and method levels.
-
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) {
…
} -
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.
Web Service Testing Interview Questions
Web Service Testing Tutorial
Web Services Interview Questions
Web Services Tutorial
Core Java Interview Questions
Java-Springs Interview Questions
Core Java Tutorial
CSS Interview Questions
Web Service Testing Interview Questions
Java-Springs Tutorial
Java Abstraction Interview Questions
CSS Tutorial
Restful web service Interview Questions
Web Services Interview Questions
Restful web service Tutorial
Amazon Web Services (AWS) Interview Questions
Spring MVC Framework Tutorial
Spring MVC Framework Interview Questions
Core Java Interview Questions
Soap Web Services Interview Questions
Java-Springs Interview Questions
CSS Interview Questions
Java Abstraction Interview Questions