Search Tutorials


Spring Cloud Quiz - MCQ - Multiple Choice Questions | JavaInUse

Spring Cloud Quiz - MCQ - Multiple Choice Questions

Q. What is the purpose of Spring Cloud?

A. To build distributed systems
B. To manage cloud infrastructure
C. To integrate APIs
D. To provide microservices architecture

Q. What is the function of Eureka in Spring Cloud?

A. Service discovery and registration
B. Load balancing
C. Circuit breaking
D. API gateway

Q. Which component of Spring Cloud is responsible for API gateway functionality?

A. Eureka
B. Zuul
C. Hystrix
D. Ribbon

Q. What is the purpose of the Ribbon component in Spring Cloud?

A. Service discovery and registration
B. Load balancing
C. Circuit breaking
D. API gateway

Q. Which component of Spring Cloud is responsible for circuit breaking functionality?

A. Eureka
B. Zuul
C. Hystrix
D. Ribbon

Q. What is the purpose of the Config Server component in Spring Cloud?

A. Service discovery and registration
B. Load balancing
C. Configuration management
D. API gateway

Q. Which component of Spring Cloud is responsible for service discovery and registration?

A. Eureka
B. Zuul
C. Hystrix
D. Ribbon

Q. What is the purpose of the Feign component in Spring Cloud?

A. Service discovery and registration
B. Load balancing
C. Circuit breaking
D. Declarative REST client

Q. What is the purpose of the Hystrix component in Spring Cloud?

A. To produce results
B. To consume values
C. To provide fault tolerance
D. To transform values

Q. What is the purpose of the Zuul component in Spring Cloud?

A. Service discovery and registration
B. Load balancing
C. Circuit breaking
D. API gateway

Q. Which annotation is used to define a Spring Boot REST Controller?

A.
@RestController
B.
@Controller
C.
@RequestMapping
D.
@ResponseBody

Q. Which annotation is used to handle GET requests in a Spring Boot REST Controller?

A.
@PostMapping
B.
@GetMapping
C.
@PutMapping
D.
@DeleteMapping





Q. Which annotation is used to define the base URL for a group of request mappings in a Spring Boot REST Controller?

A.
@RequestMapping
B.
@RestController
C.
@Controller
D.
@ResponseStatus

Q. Which of the following code snippets demonstrates the correct usage of @PathVariable annotation in a Spring Boot REST Controller method?

A.
@GetMapping("/hello/{name}")
public String hello(@PathVariable String name) {
    return "Hello, " + name + "!";
}
B.
@GetMapping("/hello/{name}")
public String hello(@RequestParam String name) {
    return "Hello, " + name + "!";
}
C.
@GetMapping("/hello")
public String hello(@PathVariable String name) {
    return "Hello, " + name + "!";
}
D.
@GetMapping("/hello")
public String hello(@RequestParam String name) {
    return "Hello, " + name + "!";
}

Q. Which annotation is used to mark a method return value to be serialized as the response body of the HTTP request in a Spring Boot REST Controller?

A.
@ResponseBody
B.
@RequestMapping
C.
@RestController
D.
@ResponseStatus

Q. Which annotation should be used to handle exceptions in a Spring Boot REST Controller?

A.
@ExceptionHandler
B.
@ResponseStatus
C.
@RequestBody
D.
@ResponseBody

Q. Which annotation should be used to define a custom status code for a method in a Spring Boot REST Controller?

A.
@ResponseBody
B.
@RequestMapping
C.
@ResponseStatus
D.
@RestController

Q. Which of the following code snippets demonstrates the correct usage of @RequestBody annotation in a Spring Boot REST Controller method?

A.
@PostMapping("/hello")
public String hello(@RequestBody String body) {
    return "Hello, " + body + "!";
}
B.
@GetMapping("/hello")
public String hello(@RequestParam String name) {
    return "Hello, " + name + "!";
}
C.
@PostMapping("/hello")
public String hello(@PathParam String name) {
    return "Hello, " + name + "!";
}
D.
@GetMapping("/hello")
public String hello(@RequestBody String body) {
    return "Hello, " + body + "!";
}

Q. Which annotation should be used to specify the HTTP method for a method in a Spring Boot REST Controller?

A.
@RequestMapping
B.
@ResponseBody
C.
@Controller
D.
@RequestMethod

Q. Which annotation should be used to specify the base URL for a group of request mappings in a Spring Boot REST Controller?

A.
@RequestMapping
B.
@ResponseBody
C.
@RestController
D.
@Controller