Top Xx Trammel Balance Interview Questions Answers For Java/Jee Programmers
Hello guys, I receive got been sharing roughly REST amongst Spring tutorials from final a brace of weeks together with today, I am going to portion roughly of the oft asked Spring together with REST interview questions to Java developers applying for Web developer roles. Since Spring Framework is the most pop together with the criterion framework for developing Java spider web application together with RESTful Web Services, a proficient noesis of Spring essence together with Spring MVC is expected from whatsoever senior Java developer, but if the chore description advert near REST together with Web Services, yous equally good demand to live on aware of how to develop RESTful Web Services using Spring Framework. From Spring 3.1, the framework has been enhanced a lot to back upwards many features needed for RESTFul API out-of-the-box e..g HTTPMessageConverter tin convert your HTTP response to JSON or XML yesteryear simply detecting relevant library inward classpath e.g. Jackson together with JAXB.
Spring equally 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 yesteryear every unmarried REST API e.g. converting the response to JSON.
H5N1 proficient noesis of Spring Security is equally good mandatory for developing together with safety RESTful Web Services inward the existent world. Since yous cannot brand life a non-trivial REST API without security, a proficient noesis of safety basics e.g. HTTP basic authentication, digest authentication, OAuth, together with JWT is real important.
Btw, If yous are non familiar amongst that concept, I advise yous acquire through REST amongst Spring together with Learn Spring Security Course to gain roughly sense before your Interview. These ii courses are specially designed to render yous roughly real-world sense to boost both your noesis together with sense amongst Spring MVC, REST, together with Spring Security.
What does REST stand upwards for? (answer)
REST stands for REpresentational State Transfer, which uses HTTP protocol to ship information from customer to server e.g. a mass inward the server tin live on 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 equally the resources it allows a customer to read, write, modify, together with 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 alter the resources at the server is known equally rubber operations e.g. GET together with HEAD. On the other hand, PUT, POST, together with DELETE are dangerous because they alter the resources on the server.
What are idempotent operations? Why is idempotency important? (answer)
There are roughly HTTP methods e.g. GET which hit same response no thing how many times yous usage them e.g. sending multiple GET asking to the same URI volition final result inward same response without whatsoever side-effect thus it is known equally idempotent.
On the other hand, the POST is non idempotent because if yous ship 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 cease result. You tin farther receive got RESTful Web Services to larn to a greater extent than near REST.
What are the advantages of the RestTemplate? (answer)
The RestTemplate shape is an implementation of Template method pattern inward Spring framework. Similar to other pop template classes e.g. JdbcTemplate or JmsTempalte, it equally good simplifies the interaction amongst RESTful Web Services on the customer side. You tin usage it to swallow a RESTful Web Servicer real easily equally shown inward this example.
Which HTTP methods does REST use? (answer)
REST tin usage whatsoever HTTP methods but the most pop ones are GET for retrieving a resource, POST for creating a resource, PUt for updating resources together with 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 together with to HTTP requests together with 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 amongst it. Spring uses the "Accept" header to create upwards one's hear the content type customer is expecting.
It volition together with then endeavor to divulge a registered HTTPMessageConverter that is capable of treatment that specific content-type together with usage it to convert the response into that format before sending to the client.
How to create a custom implementation of HttpMessageConverter to back upwards a novel type of request/responses? (answer)
You simply demand to create an implementation of AbstractHttpMessageConverter together with register it using the WebMvcConfigurerAdapter#extendMessageConverters() method amongst the classes which generate a novel type of request/response.
Is REST usually stateless? (answer)
Yes, REST API should live on stateless because it is based on HTTP which is equally 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 roughly information maintained at the server cease e.g. Sessions. REST specification seat a constraint to arrive stateless together with yous should proceed that inward hear spell 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 together with POST together with diverse other parameters. For examples, if yous are developing RESTful Web Service using Spring together with then yous tin usage produces together with consumes belongings along amongst media type notation to dot that this method is solely used to hit or consumers JSON equally shown below:
Is @Controller a stereotype? Is @RestController a stereotype? (answer)
Yes, both @Controller together with @RestController are stereotypes. The @Controller is genuinely a specialization of Spring's @Component stereotype annotation. This agency that shape annotated with @Controller volition equally good live on automatically live on detected yesteryear Spring container equally purpose of container's ingredient scanning process.
And, @RestController is a specialization of @Controller for RESTful spider web service. It non solely combines @ResponseBody together with @Controller notation but equally good gives to a greater extent than pregnant to your controller shape to clearly dot that it deals amongst RESTful requests.
Spring Framework may equally good usage this notation to render roughly to a greater extent than useful features related to REST API evolution inward future.
What is the deviation betwixt @Controller together with @RestController? (answer)
There are many differences between @Controller together with @RestController equally 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 meet hither to learn
When do yous demand @ResponseBody notation inward Spring MVC? (answer)
The @ResponseBody notation tin live on seat on a method to indicates that the render type should live on written straight to the HTTP response trunk (and non placed inward a Model, or interpreted equally a persuasion name).
For example:
@RequestMapping(path = "/hello", method = RequestMethod.PUT)
@ResponseBody
public String helloWorld() {
return "Hello World";
}
Alternatively, yous tin equally good usage @RestController notation instead of @Controller annotation. This volition take the demand for using @ResponseBody because equally discussed inward the previous answer, it comes automatically amongst @RestController annotation.
What does @PathVariable do inward Spring MVC? Why it's useful inward REST amongst 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 purpose of URI.This questions is usually asked to experienced Spring MVC developers e.g. iv to half dozen years of experience.
For example, inward the URL http://myapp.com/books/101 if yous desire to extract 101 the id, together with then yous tin use @PathVariable notation of Spring MVC. If yous are non familiar amongst Spring MVC annotations then Spring MVC For Beginners: Build Java Web App inward 25 Steps is a proficient house to get-go with.
What is the HTTP condition render code for a successful DELETE statement? (answer)
There is no strict dominion amongst honor 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 performance is successful together with the response trunk is empty render 204. If the DELETE asking is successful together with the response trunk is NOT empty, render 200
What does CRUD mean? (answer)
CRUD is a brusk shape of Create, Read, Update together with 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 together with DELETE is used to take a resources from the server.This i is roughly other beginner score 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 upwards for @Controller-annotated classes that usage @RequestMapping to map incoming requests to handler methods non already familiar amongst Spring's back upwards for Java configuration, Spring Master Class on Udemy is a proficient house to start.
This may operate for a human user but non for REST clients. You demand to ship them proper condition code e.g. 404 if the resources is non found. That's where yous tin usage @ResponseStatus annotation, which allows yous to ship custom HTTP condition code along amongst proper mistake message inward instance of Exception.
In lodge to usage it, yous tin create custom exceptions together with annotated them using @ResponseStatus notation together with proper HTTP condition code together with reason.
When such exceptions are thrown from controller's handler methods together with non handled anywhere else, together with then appropriate HTTP response amongst the proper HTTP condition code, which yous receive got laid is sent to the client.
For example, if yous are writing a RESTful Web Service for a library which provides mass information together with then yous tin use @ResponseStatus to create Exception which returns HTTP response code 404 when a mass is non constitute instead of Internal Server Error (500), equally shown below:
@ResponseStatus(value=HttpStatus.NOT_FOUND, reason="No such Book") // 404
public shape BookNotFoundException extends RuntimeException {
// ...
}
If this Exception is thrown from whatsoever handler method together with then HTTP mistake code 404 amongst argue "No such Book" volition live on returned to the client.
Is REST secure? What tin yous do to secure it? (answer)
This interrogation is generally asked amongst experienced Java programmers e.g. 2 to v years sense amongst both REST together with Spring. Security is a wide term, it could hateful safety of message which is provided yesteryear encryption or access restriction which is provided using authentication together with authorization. REST is usually non secure but yous tin secure it yesteryear using Spring security.
At the real to the lowest degree yous tin enable HTTP basic authentication yesteryear using HTTP inward your Spring safety configuration file. Similarly, yous tin expose your REST API using HTTPS if the underlying server supports HTTPS.
Does REST operate amongst carry layer safety (TLS)? (answer)
TLS or Transport Layer Security is used for secure communication betwixt customer together with server. It is the successor of SSL (Secure Socket Layer). Since HTTPS tin operate amongst both SSL together with TLS, REST tin equally good operate amongst TLS.
Actually, REST says anything near Security, it's upwards to the server which implements that. Same RESTful Web Service tin live on accessed using HTTP together with HTTPS if the server supports SSL.
If yous are using Tomcat, yous tin meet hither to larn to a greater extent than near how to enable SSL inward Tomcat.
Do yous demand Spring MVC inward your classpath for developing RESTful Web Service? (answer)
This interrogation is often asked to Java programmers amongst 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, thus yous must spring-mvc.jar or appropriate Maven entry inward your pom.xml
That's all near roughly frequently asked Spring REST Interview questions for beginners together with experienced Java JEE developers. These questions are equally good real useful to brush upwards your noesis near Spring REST if yous are going to receive got Spring Certification. If yous demand to a greater extent than questions from Spring certification perspective, yous volition divulge a lot of interrogation on this topic on David Mayer's Core Spring Simulator, i of the best simulator to move yesteryear Spring certification at the moment.
Other Spring tutorials together with Resources yous may like
Spring Master Class - Beginner to Expert
Spring Framework 5: Beginner to Guru
5 Free Courses to larn Core Spring together with Spring Boot
How Spring MVC Frameworks works?
How Basic Authentication plant inward Spring Security?
What is the Role of DispatcherServlet inward Spring?
What is deviation between @Service, @Controller, together with @Component inward Spring
REST With Spring Certification Course yesteryear Baeldung
Thanks for reading this article, if yous similar this article together with then delight portion amongst your friends together with colleagues. If yous receive got whatsoever interrogation which is non answered on this listing together with then delight driblet a comment together with I'll endeavor my best to divulge an reply for you.
Spring equally 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 yesteryear every unmarried REST API e.g. converting the response to JSON.
H5N1 proficient noesis of Spring Security is equally good mandatory for developing together with safety RESTful Web Services inward the existent world. Since yous cannot brand life a non-trivial REST API without security, a proficient noesis of safety basics e.g. HTTP basic authentication, digest authentication, OAuth, together with JWT is real important.
Btw, If yous are non familiar amongst that concept, I advise yous acquire through REST amongst Spring together with Learn Spring Security Course to gain roughly sense before your Interview. These ii courses are specially designed to render yous roughly real-world sense to boost both your noesis together with sense amongst Spring MVC, REST, together with Spring Security.
20 Spring REST Web Service Interview Questions
Here are a brace of oft asked questions near using REST Web Services inward Spring Framework.What does REST stand upwards for? (answer)
REST stands for REpresentational State Transfer, which uses HTTP protocol to ship information from customer to server e.g. a mass inward the server tin live on 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 equally the resources it allows a customer to read, write, modify, together with 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 alter the resources at the server is known equally rubber operations e.g. GET together with HEAD. On the other hand, PUT, POST, together with DELETE are dangerous because they alter the resources on the server.
What are idempotent operations? Why is idempotency important? (answer)
There are roughly HTTP methods e.g. GET which hit same response no thing how many times yous usage them e.g. sending multiple GET asking to the same URI volition final result inward same response without whatsoever side-effect thus it is known equally idempotent.
On the other hand, the POST is non idempotent because if yous ship 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 cease result. You tin farther receive got RESTful Web Services to larn to a greater extent than near REST.
What are the advantages of the RestTemplate? (answer)
The RestTemplate shape is an implementation of Template method pattern inward Spring framework. Similar to other pop template classes e.g. JdbcTemplate or JmsTempalte, it equally good simplifies the interaction amongst RESTful Web Services on the customer side. You tin usage it to swallow a RESTful Web Servicer real easily equally shown inward this example.
Which HTTP methods does REST use? (answer)
REST tin usage whatsoever HTTP methods but the most pop ones are GET for retrieving a resource, POST for creating a resource, PUt for updating resources together with 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 together with to HTTP requests together with 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 amongst it. Spring uses the "Accept" header to create upwards one's hear the content type customer is expecting.
It volition together with then endeavor to divulge a registered HTTPMessageConverter that is capable of treatment that specific content-type together with usage it to convert the response into that format before sending to the client.
How to create a custom implementation of HttpMessageConverter to back upwards a novel type of request/responses? (answer)
You simply demand to create an implementation of AbstractHttpMessageConverter together with register it using the WebMvcConfigurerAdapter#extendMessageConverters() method amongst the classes which generate a novel type of request/response.
Is REST usually stateless? (answer)
Yes, REST API should live on stateless because it is based on HTTP which is equally 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 roughly information maintained at the server cease e.g. Sessions. REST specification seat a constraint to arrive stateless together with yous should proceed that inward hear spell 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 together with POST together with diverse other parameters. For examples, if yous are developing RESTful Web Service using Spring together with then yous tin usage produces together with consumes belongings along amongst media type notation to dot that this method is solely used to hit or consumers JSON equally 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 hit JSON or XML. If yous are non familiar amongst these annotations together with then I advise yous bring together Spring MVC For Beginners course of report on Udemy to larn from scratch.
Is @Controller a stereotype? Is @RestController a stereotype? (answer)
Yes, both @Controller together with @RestController are stereotypes. The @Controller is genuinely a specialization of Spring's @Component stereotype annotation. This agency that shape annotated with @Controller volition equally good live on automatically live on detected yesteryear Spring container equally purpose of container's ingredient scanning process.
And, @RestController is a specialization of @Controller for RESTful spider web service. It non solely combines @ResponseBody together with @Controller notation but equally good gives to a greater extent than pregnant to your controller shape to clearly dot that it deals amongst RESTful requests.
Spring Framework may equally good usage this notation to render roughly to a greater extent than useful features related to REST API evolution inward future.
What is the deviation betwixt @Controller together with @RestController? (answer)
There are many differences between @Controller together with @RestController equally 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 meet hither to learn
When do yous demand @ResponseBody notation inward Spring MVC? (answer)
The @ResponseBody notation tin live on seat on a method to indicates that the render type should live on written straight to the HTTP response trunk (and non placed inward a Model, or interpreted equally a persuasion name).
For example:
@RequestMapping(path = "/hello", method = RequestMethod.PUT)
@ResponseBody
public String helloWorld() {
return "Hello World";
}
Alternatively, yous tin equally good usage @RestController notation instead of @Controller annotation. This volition take the demand for using @ResponseBody because equally discussed inward the previous answer, it comes automatically amongst @RestController annotation.
What does @PathVariable do inward Spring MVC? Why it's useful inward REST amongst 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 purpose of URI.This questions is usually asked to experienced Spring MVC developers e.g. iv to half dozen years of experience.
For example, inward the URL http://myapp.com/books/101 if yous desire to extract 101 the id, together with then yous tin use @PathVariable notation of Spring MVC. If yous are non familiar amongst Spring MVC annotations then Spring MVC For Beginners: Build Java Web App inward 25 Steps is a proficient house to get-go with.
What is the HTTP condition render code for a successful DELETE statement? (answer)
There is no strict dominion amongst honor 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 performance is successful together with the response trunk is empty render 204. If the DELETE asking is successful together with the response trunk is NOT empty, render 200
What does CRUD mean? (answer)
CRUD is a brusk shape of Create, Read, Update together with 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 together with DELETE is used to take a resources from the server.This i is roughly other beginner score 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>
It enables back upwards for @Controller-annotated classes that usage @RequestMapping to map incoming requests to handler methods non already familiar amongst Spring's back upwards for Java configuration, Spring Master Class on Udemy is a proficient house to start.
When do yous demand @ResponseStatus notation inward Spring MVC? (answer)
H5N1 proficient questions for iii to v years experienced leap developers. The @ResponseStatus notation is required during mistake treatment inward Spring MVC together with 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 operate for a human user but non for REST clients. You demand to ship them proper condition code e.g. 404 if the resources is non found. That's where yous tin usage @ResponseStatus annotation, which allows yous to ship custom HTTP condition code along amongst proper mistake message inward instance of Exception.
In lodge to usage it, yous tin create custom exceptions together with annotated them using @ResponseStatus notation together with proper HTTP condition code together with reason.
When such exceptions are thrown from controller's handler methods together with non handled anywhere else, together with then appropriate HTTP response amongst the proper HTTP condition code, which yous receive got laid is sent to the client.
For example, if yous are writing a RESTful Web Service for a library which provides mass information together with then yous tin use @ResponseStatus to create Exception which returns HTTP response code 404 when a mass is non constitute instead of Internal Server Error (500), equally shown below:
@ResponseStatus(value=HttpStatus.NOT_FOUND, reason="No such Book") // 404
public shape BookNotFoundException extends RuntimeException {
// ...
}
If this Exception is thrown from whatsoever handler method together with then HTTP mistake code 404 amongst argue "No such Book" volition live on returned to the client.
Is REST secure? What tin yous do to secure it? (answer)
This interrogation is generally asked amongst experienced Java programmers e.g. 2 to v years sense amongst both REST together with Spring. Security is a wide term, it could hateful safety of message which is provided yesteryear encryption or access restriction which is provided using authentication together with authorization. REST is usually non secure but yous tin secure it yesteryear using Spring security.
At the real to the lowest degree yous tin enable HTTP basic authentication yesteryear using HTTP inward your Spring safety configuration file. Similarly, yous tin expose your REST API using HTTPS if the underlying server supports HTTPS.
Does REST operate amongst carry layer safety (TLS)? (answer)
TLS or Transport Layer Security is used for secure communication betwixt customer together with server. It is the successor of SSL (Secure Socket Layer). Since HTTPS tin operate amongst both SSL together with TLS, REST tin equally good operate amongst TLS.
Actually, REST says anything near Security, it's upwards to the server which implements that. Same RESTful Web Service tin live on accessed using HTTP together with HTTPS if the server supports SSL.
If yous are using Tomcat, yous tin meet hither to larn to a greater extent than near how to enable SSL inward Tomcat.
Do yous demand Spring MVC inward your classpath for developing RESTful Web Service? (answer)
This interrogation is often asked to Java programmers amongst 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, thus yous must spring-mvc.jar or appropriate Maven entry inward your pom.xml
That's all near roughly frequently asked Spring REST Interview questions for beginners together with experienced Java JEE developers. These questions are equally good real useful to brush upwards your noesis near Spring REST if yous are going to receive got Spring Certification. If yous demand to a greater extent than questions from Spring certification perspective, yous volition divulge a lot of interrogation on this topic on David Mayer's Core Spring Simulator, i of the best simulator to move yesteryear Spring certification at the moment.
Other Spring tutorials together with Resources yous may like
Spring Master Class - Beginner to Expert
Spring Framework 5: Beginner to Guru
5 Free Courses to larn Core Spring together with Spring Boot
How Spring MVC Frameworks works?
How Basic Authentication plant inward Spring Security?
What is the Role of DispatcherServlet inward Spring?
What is deviation between @Service, @Controller, together with @Component inward Spring
REST With Spring Certification Course yesteryear Baeldung
Thanks for reading this article, if yous similar this article together with then delight portion amongst your friends together with colleagues. If yous receive got whatsoever interrogation which is non answered on this listing together with then delight driblet a comment together with I'll endeavor my best to divulge an reply for you.



0 Response to "Top Xx Trammel Balance Interview Questions Answers For Java/Jee Programmers"
Post a Comment