Spring Boot – API Cantabile Interview Question-Answer

Q.1 Which is the class that has to be autowired with the controller class for invoking processes?

       A. Entity

       B. Model

       C. Service

       D. Any of the options

       E. None of the options

Ans : Service


Q.2 Which Spring annotation can be used to expose a controller as REST API?

       A. @Controller

       B. @RestAPIController

       C. @RestController

       D. None of the options

Ans : @RestController


Q.3 @RequestMapping(value = “/hospitals/{id}”, method = RequestMethod.GET) How to get the value of id in controller method?

       A. @Variable(“id”)

       B. @PathVariable(“id”)

       C. @RequestMapping(“id”)

       D. @RequestVariable(“id”)

Ans : @PathVariable(“id”)


Q.4 Spring Boot Microservices are loosly coupled, independent, constrained and abstracted.

       A. True

       B. False

Ans : True


Q.5 Embedded database support has persistent data storage.

       A. True

       B. False

Ans : False


Q.6 Which REST Service API cannot be created using Spring Boot?

       A. Account Service

       B. Order Service

       C. Payment Service

       D. Rating Service

       E. All the options

       F. None of the options

Ans : None of the options


Q.7 What is the dependency to be added to configure JPA to Spring Boot Project?

       A. Spring-boot-starter-data

       B. Spring-boot-starter-data-jpa

       C. Spring-boot-starter-jpa

       D. None of the options

Ans : Spring-boot-starter-data-jpa


Q.8 ________ can be used to over a SQL as well as NoSQL database.

       A. Spring Data

       B. Spring JDBCTemplate

       C. Spring JPA

       D. None of the options

Ans : Spring Data


Q.9 Embedded DB support is not available for ___________.

       A. Derby

       B. H2

       C. HSQL

       D. Oracle

Ans : Oracle


Q.10 In Basic authentication, username and password are

       A. base16 encoded

       B. base64 encoded

       C. RSA encrypted

       D. sha256 hashed

Ans : base64 encoded


Q.11 Which is not a valid method in RestTemplate to get http request?

       A. getForLocation

       B. getForObject

       C. getForEntity

       D. None of the options

Ans : getForLocation


Q.12 Which is the correct format for HTTP Basic security technique?

       A. Authorization: Basic dm9yZGVsOnZvcmRlbA==

       B. Authorization: dm9yZGVsOnZvcmRlbA==

       C. None of the options

Ans : Authorization: Basic dm9yZGVsOnZvcmRlbA==


Q.13 Spring Boot offers ______ template to consume REST Services.

       A. MockMVC

       B. RestMVC

       C. RestTemplate

       D. None of the options

Ans : RestTemplate


Q.14 In Spring Boot, unit testing can be done on ______ class.

       A. Controller

       B. Repository

       C. Service

       D. All the options

Ans : All the options


Q.15 Which is the class level annotation that is used to test Repository class?

       A. @DataTest

       B. @DataJpaTest

       C. @JpaTest

       D. All the options

Ans : @DataJpaTest


Q.16 Which annotation can be used to run quick unit tests?

       A. @IntegrateTest

       B. @SpringBootTest

       C. @IntTest

       D. @SpringTest

Ans : @SpringBootTest


Q.17 _________ class has to be auto wired to the Repository test class to test Repository class.

       A. TestEntityManager

       B. TestDataEntity

       C. Both the options

       D. None of the options

Ans : TestEntityManager


Q.18 What is the technique used to do unit testing on a Controller class?

       A. RestMvc

       B. MockMvc

       C. TestMvc

       D. All the options

Ans : MockMvc


Q.19 Repository class has to extend ______ class to get the implementation benefit of Spring Data.

       A. CrudRepositoryTest

       B. CrudRep

       C. CrudRepository

       D. No Class needs to extended

Ans : CrudRepository


Q.20 Which is not a valid method in RestTemplate to http post request?

       A. postForObject

       B. postForLocation

       C. Both the options

       D. None of the options

Ans : None of the options


Leave a Comment