Search Interview Questions | More than 3000 questions in repository. There are more than 900 unanswered questions. Click here and help us by providing the answer. Have a video suggestion. Click Correct / Improve and please let us know. |
|
| ||||
Interview Questions and Answers for 'Rest' - 35 question(s) found - Order By Newest | ||||
| ||||
Ans. public static void main(String ar[]) { int n=5; if((n/2)*2==n) { System.out.println("Even Number "); } else { System.out.println("Odd Number "); } } | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   code   coding   tricky questions   interesting questions   modulus operator Asked in 4 Companies   frequent | ||||
Very frequently asked in companies using SOA. | ||||
| ||||
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. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   web services   rest   java   j2ee  architecture Asked in 14 Companies intermediate   frequent | ||||
| ||||
Ans. GET is supposed to get information from the server. Client sends the minimal information so that Server can respond with the response body on basis of request. For example - You want to get complete employment record for employee id 123 POST is supposed to send the information for submission. Payload or a Body is usually sent so that it can be persisted on the server. For example - Sending the complete information of an employee ( id, name , dept etc ) to the server for persisting it. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  get vs post   web service   rest Asked in 11 Companies basic   frequent | ||||
| ||||
Ans. true, due to String Pool, both will point to a same String object. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   code   coding   tricky questions   interesting questions   string   string pool   .equal   == intermediate   frequent | ||||
| ||||
Ans. Compile time error as it won't find the constructor matching BuggyBread2(). Compiler won't provide default no argument constructor as programmer has already defined one constructor. Compiler will treat user defined BuggyBread2() as a method, as return type ( void ) has been specified for that. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   code   coding   tricky questions   interesting questions   default constructor   constructor | ||||
Try 3 Question(s) Test | ||||
| ||||
Ans. Selenium WebDriver is a tool for automating web application testing.It helps in replicating the manual tester behavior like keyboard entry, mouse events etc and then matching the output against the expected. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  selenium  webdriver Asked in 37 Companies | ||||
| ||||
Ans. SOAP services are better in case we need to establish a formal and detail contract with the client or callers and hence suitable for 1. Services published for much wider unknown audience 2. Require large input payload 3. Requiring different level for authentication | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  soap vs rest  soap  rest Asked in 2 Companies | ||||
| ||||
Ans. 1. Enforcing composition over inheritance 2. Restricting overriding of certain methods 3. Final methods are faster than regular instance methods 4. Enforcing Immutability | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  final class   reasons for final class   restricting inheritance  object oriented programming (oops)  oops concepts expert | ||||
| ||||
Ans. We can do that by pulling binary representation using 3 bits ( random(2) ). getRandom7() { String binaryStr = String.valuesOf(random(2))+String.valuesOf(random(2))+String.valuesOf(random(2)); binaryInt = Integer.valueOf(binaryStr); int sumValue=0; int multiple = 1; while(binaryInt > 0){ binaryDigit = binaryInt%10; binaryInt = binaryInt /10; sumValue = sumValue + (binaryDigit * multiple); multiple = multiple * 2; } } | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   tricky question   interesting questions   google interview questions   random | ||||
| ||||
Ans. convert(int binaryInt) { int sumValue=0; int multiple = 1; while(binaryInt > 0){ binaryDigit = binaryInt%10; binaryInt = binaryInt /10; sumValue = sumValue + (binaryDigit * multiple); multiple = multiple * 2; } return sumValue; } | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   binary   interesting question   coding | ||||
| ||||
Ans. XML and JSON ( Javascript Object Notation ). | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   web services   rest   java   j2ee   xml   json   architecture basic   frequent | ||||
| ||||
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. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  rest   webservices   web servuces   http   architecture   technical architect | ||||
| ||||
Ans. Jersey , Restlet , RestX, Spring , RestEasy ,Restfulie, Play Framework | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  java   rest   web services   frameworks | ||||
| ||||
Ans. eq, ge, gt , between, in , isNull, isEmpty, isNotnull, ne , like, lt , or , not | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  hibernate   hibernate criteria   hibernate restriction | ||||
| ||||
Ans. Controller | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  spring frmaework   spring mvc   rest   webservices | ||||
| ||||
Ans. Request Body in case of Get Request has no meaning and hence it's not parsed when the request is received. Alternatively Request Parameters are passed as either Path Params or Query Params. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  rest  web services  http  http methods  get request | ||||
Frequently asked question in companies using Rest Web services. | ||||
| ||||
Ans. PUT requests are only meant to place the object as it is on server. For example - You want a file to be uploaded and then placed in a particular folder or you want an Employee object to be persisted in the table. POST requests are also meant to transfer information from client to server but that information once received at the server is evaluated , modified or refactored before persisting. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  Put vs Post   Rest Asked in 5 Companies   frequent | ||||
| ||||
Ans. It should be a POST Request | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  Put vs Post   Rest Asked in 1 Companies | ||||
| ||||
Ans. It depends on whether the request object is persisted as it is or its first dismantled, modified or refactored and then inserted into DB. In first case, it should be a PUT request whereas in second case it should be a POST Request. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  Put vs Post   Rest Asked in 2 Companies intermediate   frequent | ||||
| ||||
Ans. No, we can also send an empty body with the POST Request. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  Get Request   Rest   rare | ||||
| ||||
Ans. We can send it but it's completely ignored by the server. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  Get Request   Rest | ||||
| ||||
Ans. No, even if there is no payload, you can't hit the POST request by typing it into browser address bar. You will need a client that can make a POST Request. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  Post Request   Rest  Calling Rest service through browser   rare | ||||
| ||||
Ans. 1. As Request Param 2. As Path Param 3. Part of Payload / Body in case of PUT and POST Request | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  web service   rest basic   frequent | ||||
| ||||
Ans. session.createCriteria(Employee.class).add( Restrictions.or(Restrictions.like("name", "A%"),Restrictions.like("name", "B%"))).list(); | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  hibernate  Criteria  Restrictions | ||||
| ||||
Ans. There is no direct way to make stateful REST service but when first time request send to server, generate the token on server and send back to client. When every time new request is send the token is send to identify the request is coming from same client. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  Rest  Web Services Asked in 1 Companies | ||||
| ||||
Ans. If the number of input values is large, we can go about passing them as query params instead of path params. If the number is even larger and complex , its better to create a post service that behaves like a get service. Though this practice is not recommended but technically it can be accomplished.I dont mind doing it if the exceptionally large number of input would make it much more confusing. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  rest  restful web services | ||||
| ||||
Ans. Generally Rest services don't have any registry like we have WSDL is SOAP and hence don't have a way to know the end points without looking at either the url mapping in controller or client code. Some restful service publish WADL (Web Application Description Language) and hence clients can locate the service end points. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  rest api endpoints | ||||
| ||||
Ans. is not equals anyOf hasSize | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  assertThat.hamcrest | ||||
| ||||
Ans. If the number of params is quite large , I would prefer to either split it with majority of it in query params or all in query params. If the params are all mandatory , I would keep it as path params. If it's optional , I would keep it as query param so as to keep consistent base url. If we don't require the param name , then they can be kept as path params as query params necessitates the usage of param name. | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  Web Service  Get service  path vs query param  Rest  query param  path param | ||||
| ||||
Ans. No, it's optional as the name of path param required is same as method param name in this case. Even the declaration as following should work - @Path("/{employeeId}") public String employeeInfo(@PathParam Long employeeId){ } | ||||
Help us improve. Please let us know the company, where you were asked this question : | ||||
Like Discuss Correct / Improve  Web Service  Get service  Rest  path param | ||||