Top Xx Jump Balance Interview Questions Answers For Java/Jee Programmers

Advertisement

Masukkan script iklan 970x90px

Top Xx Jump Balance Interview Questions Answers For Java/Jee Programmers

Jumat, 27 Maret 2020

Hello guys, I direct hold been sharing closed to REST alongside Spring tutorials from concluding a brace of weeks in addition to today, I am going to part closed to of the often asked Spring in addition to REST interview questions to Java developers applying for Web developer roles. Since Spring Framework is the most pop in addition to the touchstone framework for developing Java spider web application in addition to RESTful Web Services, a skillful cognition of Spring inwardness in addition to Spring MVC is expected from whatever senior Java developer, but if the undertaking description call close REST in addition to Web Services, yous every bit good demand to last aware of how to develop RESTful Web Services using Spring Framework. From Spring 3.1, the framework has been enhanced a lot to back upward many features needed for RESTFul API out-of-the-box e..g HTTPMessageConverter tin convert your HTTP response to JSON or XML past times but detecting relevant library inward classpath e.g. Jackson in addition to JAXB.

Spring every bit good provides customized annotations for RESTful Web Services e.g. @RestController which tin brand your Controller REST aware, so that yous don't demand to do mutual materials required past times every unmarried REST API e.g. converting the response to JSON.

H5N1 skillful cognition of Spring Security is every bit good mandatory for developing in addition to safety RESTful Web Services inward the existent world. Since yous cannot brand life a non-trivial REST API without security, a skillful cognition of safety basics e.g. HTTP basic authentication, digest authentication, OAuth, in addition to JWT is really important.

Btw, If yous are non familiar alongside that concept, I propose yous acquire through REST alongside Spring in addition to Learn Spring Security Course to gain closed to sense before your Interview. These 2 courses are specially designed to furnish yous closed to real-world sense to boost both your cognition in addition to sense alongside Spring MVC, REST, in addition to Spring Security.



20 Spring REST Web Service Interview Questions 

Here are a brace of often asked questions close using REST Web Services inward Spring Framework.

What does REST stand upward for? (answer)
REST stands for REpresentational State Transfer, which uses HTTP protocol to shipping information from customer to server e.g. a mass inward the server tin last delivered to the customer using JSON or XML.


What is a resource? (answer)
H5N1 resources is how information is represented inward REST architecture. By exposing entities every bit the resources it allows a customer to read, write, modify, in addition to create resources using HTTP methods e.g. GET, POST, PUT, DELETE etc.


What are rubber REST operations? (answer)
REST API uses HTTP methods to perform operations. Some of the HTTP operations which doesn't alteration the resources at the server is known every bit rubber operations e.g. GET in addition to HEAD. On the other hand, PUT, POST, in addition to DELETE are dangerous because they alteration the resources on the server.


What are idempotent operations? Why is idempotency important? (answer)
There are closed to HTTP methods e.g. GET which create same response no affair how many times yous utilisation them e.g. sending multiple GET asking to the same URI volition final result inward same response without whatever side-effect thence it is known every bit idempotent.

On the other hand, the POST is non idempotent because if yous shipping multiple POST request, it volition final result inward multiple resources creation on the server, but again, PUT is idempotent if yous are using it to update the resource.

Even, multiple PUT asking to update a resources on a server volition give same goal result. You tin farther direct hold RESTful Web Services to larn to a greater extent than close REST.


What are the advantages of the RestTemplate? (answer)
The RestTemplate degree is an implementation of Template method pattern inward Spring framework. Similar to other pop template classes e.g. JdbcTemplate or JmsTempalte, it every bit good simplifies the interaction alongside RESTful Web Services on the customer side. You tin utilisation it to swallow a RESTful Web Servicer really easily every bit shown inward this example.


Which HTTP methods does REST use? (answer)
REST tin utilisation whatever HTTP methods but the most pop ones are GET for retrieving a resource, POST for creating a resource, PUt for updating resources in addition to DELETE for removing a resources from the server.



What is an HttpMessageConverter inward Spring REST? (answer)
An HttpMessageConverter is a Strategy interface that specifies a converter that tin convert from in addition to to HTTP requests in addition to responses. Spring REST uses this interface to convert HTTP response to diverse formats e.g. JSON or XML.

Each HttpMessageConverter implementation has i or several MIME Types associated alongside it. Spring uses the "Accept" header to create upward one's heed the content type customer is expecting.

It volition in addition to then endeavor to disclose a registered HTTPMessageConverter that is capable of treatment that specific content-type in addition to utilisation it to convert the response into that format before sending to the client.



How to create a custom implementation of HttpMessageConverter to back upward a novel type of request/responses? (answer)
You but demand to create an implementation of AbstractHttpMessageConverter in addition to register it using the WebMvcConfigurerAdapter#extendMessageConverters() method alongside the classes which generate a novel type of request/response.


Is REST unremarkably stateless? (answer)
Yes, REST API should last stateless because it is based on HTTP which is every bit good stateless. H5N1 Request inward REST API should comprise all the details required it to procedure i.e. it should non rely on previous or adjacent asking or closed to information maintained at the server goal e.g. Sessions. REST specification pose a constraint to acquire inward stateless in addition to yous should continue that inward heed piece designing your REST API.


What does @RequestMapping notation do? (answer)
The @RequestMapping notation is used to map spider web requests to Spring Controller methods. You tin map asking based upon HTTP methods  e.g. GET in addition to POST in addition to diverse other parameters. For examples, if yous are developing RESTful Web Service using Spring in addition to then yous tin utilisation produces in addition to consumes belongings along alongside media type notation to dot that this method is exclusively used to create or consumers JSON every bit shown below:

@RequestMapping (method = RequestMethod.POST, consumes="application/json") public Book save(@RequestBody Book aBook) {    return bookRepository.save(aBook); }
You tin similarly create other handler methods to create JSON or XML. If yous are non familiar alongside these annotations in addition to then I propose yous bring together Spring MVC For Beginners course of educational activity on Udemy to larn from scratch.



Is @Controller a stereotype? Is @RestController a stereotype? (answer)
Yes, both @Controller in addition to @RestController are stereotypes. The @Controller is genuinely a specialization of Spring's @Component stereotype annotation. This agency that degree annotated with @Controller volition every bit good last automatically last detected past times Spring container every bit business office of container's factor scanning process.

And, @RestController is a specialization of @Controller for RESTful spider web service. It non exclusively combines @ResponseBody in addition to @Controller notation but every bit good gives to a greater extent than important to your controller degree to clearly dot that it deals alongside RESTful requests.

Spring Framework may every bit good utilisation this notation to furnish closed to to a greater extent than useful features related to REST API evolution inward future.


What is the divergence betwixt @Controller in addition to @RestController?  (answer)
There are many differences between @Controller in addition to @RestController every bit discussed inward my before article (see the answer) but the most of import i is that with @RestController yous acquire the @ResponseBody notation automatically, which agency yous don't demand to separately annotate your handler methods with @ResponseBody annotation. This makes the evolution of RESTful spider web service easier using Spring. You tin run into hither to learn

 I direct hold been sharing closed to REST alongside Spring tutorials from concluding a brace of weeks in addition to today Top xx Spring REST Interview Questions Answers for Java/JEE Programmers



When do yous demand @ResponseBody notation inward Spring MVC? (answer)
The @ResponseBody notation tin last pose on a method to indicates that the render type should last written straight to the HTTP response trunk (and non placed inward a Model, or interpreted every bit a persuasion name).

For example:

@RequestMapping(path = "/hello", method = RequestMethod.PUT)
@ResponseBody
public String helloWorld() {
   return "Hello World";
}

Alternatively, yous tin every bit good utilisation @RestController notation instead of @Controller annotation. This volition take the demand for using @ResponseBody because every bit discussed inward the previous answer, it comes automatically alongside @RestController annotation.



What does @PathVariable do inward Spring MVC? Why it's useful inward REST alongside Spring? (answer)
It's i of the useful annotations from Spring MVC which allows yous to read values from URI similar query parameter. It's specially useful inward instance of creating RESTful spider web service using Spring because inward REST resources identifiers are business office of URI.This questions is unremarkably asked to experienced Spring MVC developers e.g. four to half dozen years of experience.

For example, inward the URL http://myapp.com/books/101 if yous desire to extract 101 the id, in addition to then yous tin use @PathVariable notation of Spring MVC.  If yous are non familiar alongside Spring MVC annotations then Spring MVC For Beginners: Build Java Web App inward 25 Steps is a skillful house to kickoff with.

 I direct hold been sharing closed to REST alongside Spring tutorials from concluding a brace of weeks in addition to today Top xx Spring REST Interview Questions Answers for Java/JEE Programmers



What is the HTTP condition render code for a successful DELETE statement? (answer)
There is no strict dominion alongside honour to what condition code your REST API should render later a successful DELETE i.e it tin render 200 Ok or 204 No Content. In general, if the DELETE functioning is successful in addition to the response trunk is empty render 204. If the DELETE asking is successful in addition to the response trunk is NOT empty, render 200


What does CRUD mean? (answer)
CRUD is a brusk shape of Create, Read, Update in addition to Delete. In REST API, the POST is used to create a resource, GET is used to read a resource, PUT is used to updated a resources in addition to DELETE is used to take a resources from the server.This i is closed to other beginner bird Spring MVC questions for 1 to iii years experienced programmers


Where do yous demand @EnableWebMVC? (answer)
The @EnableWebMvc notation is required to enable Spring MVC when Java configuration is used to configure Spring MVC instead of XML. It is equivalent to <mvc: annotation-driven>  inward XML configuration.

It enables back upward for @Controller-annotated classes that utilisation @RequestMapping to map incoming requests to handler methods non already familiar alongside Spring's back upward for Java configuration, Spring Master Class on Udemy is a skillful house to start.


When do yous demand @ResponseStatus notation inward Spring MVC? (answer)
H5N1 skillful questions for iii to five years experienced boundary developers. The @ResponseStatus notation is required during mistake treatment inward Spring MVC in addition to REST. Normally when an mistake or exception is thrown at server side, spider web server render a blanket HTTP condition code 500 - Internal server error.

This may run for a human user but non for REST clients. You demand to shipping them proper condition code e.g. 404 if the resources is non found. That's where yous tin utilisation @ResponseStatus annotation, which allows yous to shipping custom HTTP condition code along alongside proper mistake message inward instance of Exception.

In fellowship to utilisation it, yous tin create custom exceptions in addition to annotated them using @ResponseStatus notation in addition to proper HTTP condition code in addition to reason.

When such exceptions are thrown from controller's handler methods in addition to non handled anywhere else, in addition to then appropriate HTTP response alongside the proper HTTP condition code, which yous direct hold laid is sent to the client.

For example, if yous are writing a RESTful Web Service for a library which provides mass information in addition to then yous tin use @ResponseStatus to create Exception which returns HTTP response code 404 when a mass is non institute instead of Internal Server Error (500), every bit shown below:

 @ResponseStatus(value=HttpStatus.NOT_FOUND, reason="No such Book")  // 404
 public degree BookNotFoundException extends RuntimeException {
     // ...
 }

If this Exception is thrown from whatever handler method in addition to then HTTP mistake code 404 alongside argue "No such Book" volition last returned to the client.


Is REST secure? What tin yous do to secure it? (answer)
This query is generally asked alongside experienced Java programmers e.g. 2 to five years sense alongside both REST in addition to Spring. Security is a wide term, it could hateful safety of message which is provided past times encryption or access restriction which is provided using authentication in addition to authorization. REST is unremarkably non secure but yous tin secure it past times using Spring security.

At the really to the lowest degree yous tin enable HTTP basic authentication past times using HTTP inward your Spring safety configuration file. Similarly, yous tin expose your REST API using HTTPS if the underlying server supports HTTPS.

 I direct hold been sharing closed to REST alongside Spring tutorials from concluding a brace of weeks in addition to today Top xx Spring REST Interview Questions Answers for Java/JEE Programmers




Does REST run alongside carry layer safety (TLS)? (answer)
TLS or Transport Layer Security is used for secure communication betwixt customer in addition to server. It is the successor of SSL (Secure Socket Layer). Since HTTPS tin run alongside both SSL in addition to TLS, REST tin every bit good run alongside TLS.

Actually, REST says anything close Security, it's upward to the server which implements that. Same RESTful Web Service tin last accessed using HTTP in addition to HTTPS if the server supports SSL.

If yous are using Tomcat, yous tin run into hither to larn to a greater extent than close how to enable SSL inward Tomcat.


Do yous demand Spring MVC inward your classpath for developing RESTful Web Service? (answer)
This query is often asked to Java programmers alongside 1 to 2 years of sense inward Spring. Short reply is Yes, yous demand Spring MVC inward your Java application's classpath to develop RESTful spider web services using Spring framework. It's genuinely Spring MVC which provides all useful annotations e.g. @RestController, @ResponseCode, @ResponseBody, @RequestBody, and @PathVariable, thence yous must spring-mvc.jar or appropriate Maven entry inward your pom.xml


That's all close closed to frequently asked Spring REST Interview questions for beginners in addition to experienced Java JEE developers. These questions are every bit good really useful to brush upward your cognition close Spring REST if yous are going to direct hold Spring Certification. If yous demand to a greater extent than questions from Spring certification perspective, yous volition disclose a lot of query on this topic on David Mayer's Core Spring Simulator, i of the best simulator to overstep Spring certification at the moment.


Other Spring tutorials in addition to Resources yous may like
Spring Master Class - Beginner to Expert
Spring Framework 5: Beginner to Guru
5 Free Courses to larn Core Spring in addition to Spring Boot
How Spring MVC Frameworks works?
How Basic Authentication industrial plant inward Spring Security?
What is the Role of DispatcherServlet inward Spring?
What is divergence between @Service, @Controller, in addition to @Component inward Spring
REST With Spring Certification Course past times Baeldung

Thanks for reading this article, if yous similar this article in addition to then delight part alongside your friends in addition to colleagues. If yous direct hold whatever query which is non answered on this listing in addition to then delight drib a comment in addition to I'll endeavor my best to disclose an reply for you.