REST Web Services - Interview Questions and Answers

Q1.  What are RESTful Web Services ?

Ans. REST or Representational State Transfer is a flexible architecture style for creating web services that recommends the following guidelines - 

1. http for client server communication, 
2. XML / JSON as formatiing language , 
3. Simple URI as address for the services and, 
4. stateless communication. 

Q2.  Which markup languages can be used in restful web services ? 

Ans. XML and JSON ( Javascript Object Notation ).

Q3.  Why Web services use HTTP as the communication protocol ?

Ans. With the advent of Internet, HTTP is the most preferred way of communication. Most of the clients ( web thin client , web thick clients , mobile apps )  are designed to communicate using http only. Web Services using http makes them accessible from vast variety of client applications. 

Q4. What are the HTTP methods used in Rest Services ?

Ans. GET , PUT , POST and DELETE.

Q5. Difference between PUT and POST ?

Ans. PUT puts a file or resource at a specific URI, and exactly at that URI. If there's already a file or resource at that URI, PUT replaces that file or resource. If there is no file or resource there, PUT creates one.

POST sends data to a specific URI and expects the resource at that URI to handle the request. The web server at this point can determine what to do with the data in the context of the specified resource.