0% found this document useful (0 votes)
75 views24 pages

SpringBoot Mock Assessment 27FebPune Batch With Answers

The document contains a series of multiple-choice questions related to Spring Boot, covering topics such as annotations, configuration, RESTful services, and JPA. Each question is designed to test knowledge of Spring Boot features and best practices. The assessment includes a total of 56 questions with varying point values.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
75 views24 pages

SpringBoot Mock Assessment 27FebPune Batch With Answers

The document contains a series of multiple-choice questions related to Spring Boot, covering topics such as annotations, configuration, RESTful services, and JPA. Each question is designed to test knowledge of Spring Boot features and best practices. The assessment includes a total of 56 questions with varying point values.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 24

SpringBoot_Mock_Assessm… 60 minutes

Question - 1 SCORE: 1 points


Spring

boot

Which annotation is used to define the primary key of an entity in a Spring Boot application?

@PrimaryKey

@Primary

@Id

@GeneratedValue

Question - 2 SCORE: 1 points


Spring

boot

Which annotation is used to define a Spring Boot configuration class?

@SpringConfig

@Configuration

@AppConfig

@SpringBootConfig

Question - 3 SCORE: 1 points


Spring

boot

What is Spring Boot's embedded database for development and testing by default?

PostgreSQL

Oracle

mySql

H2

1/24
Question - 4 SCORE: 1 points
Spring

boot

Which annotation is used to create a RESTful endpoint in a Spring Boot application?

@RestController

@RequestMapping

@ResponseBody

@Service

Question - 5 SCORE: 1 points


Spring

boot

Which of the following Spring Boot starter dependencies is used for building RESTful web services?

spring-boot-starter-data-jpa

spring-boot-starter-web

spring-boot-starter-actuator

spring-boot-starter-test

Question - 6 SCORE: 1 points


Spring

boot

Which annotation is used to mark a class as a Spring Boot application?

@SpringBootApp

@EnableSpring

@SpringBootApplication

@SpringConfig

Question - 7 SCORE: 1 points


Spring

Bean

2/24
What is the purpose of the Spring framework's ApplicationContext?

To configure database connections

To define Java classes

To manage Spring Beans and provide various services

To handle web requests

Question - 8 SCORE: 1 points


Spring

Annotation

What is the purpose of the Spring @Autowired annotation?

It defines the scope of a Bean.

It specifies the name of the Bean.

It injects dependencies automatically.

It sets the initialization method of a Bean.

Question - 9 SCORE: 1 points


Springboot

spring boot

Which file is typically used to configure properties for a Spring Boot application?

application.properties

spring-config.xml

web.xml

pom.xml

build.gradle

Question - 10 SCORE: 1 points


Spring boot

Spring boot

Consider you are making a REST controller, which of the following annotation you will use to specific your
spring boot application that this is a Rest controller?

3/24
@Controller

@RestController

@GenerateController

@GenerateRESTController

Question - 11 SCORE: 1 points


Spring boot

Spring boot

Which interface do we extend to create a repository in Spring Data JPA?

Repository

JpaRepository

SpringRepository

DataJpaRepository

Question - 12 SCORE: 1 points


Spring boot

Spring boot

How can you customize the column name for a field in a JPA entity ?

@Column(name="custom_name")

@FieldName("custom_name")

@TableColumn("custom_name")

@DatabaseColumn("custom_name")

Question - 13 SCORE: 1 points


Spring boot

Spring boot

Which annotation do we use to mark the class as a Service class/component?

@Service

@Component

@ServiceRequest

@Repository

4/24
Question - 14 SCORE: 1 points
Spring boot

Spring boot

@RestController annotation is a combination of the below two annotations

@Component and @ResponseBody annotations

@Controller and @ResponseBody annotations

@Service and @ResponseBody annotations

None of the above

Question - 15 SCORE: 1 points


Spring boot

Spring boot

If you want to send the string back as it is from the controller which of the following annotation you will use?
Note: This is a controller class with the annotation of @Controller

@ResponseBody

@RequestBody

You dont have to do anything Spring boot will take care for it

It cant be done

Question - 16 SCORE: 1 points


Spring boot

Spring boot

_____________ is the annotation you use when we want to specify the Repository. And it is usually extended by __________________ and _____________ class.

@JpaRepository @CrudRepository @Repository

You can use either of the two option both are correct

@Repository @JpaRepository @CrudRepository

None of them is correct

Question - 17 SCORE: 1 points


Spring boot

Spring boot

5/24
If you want to keep the URL same in the H2 console for the application which of the following property you will need to change in application.properties?

spring.url=jdbc:h2:mem:testdb

spring.datasource.url=jdbc:h2:mem:testdb

url=jdbc:h2:mem:testdb

None of them is correct

Question - 18 SCORE: 3 points


Springboot

springboot

Which ones are Springboot features

Dependency Injection

Boilerplate Code

Auto-Configuration

None of above

All of Above

Question - 19 SCORE: 5 points


Spring boot

Spring boot MVC

Which of the following annotation can we use when we want to make a GET request for spring boot application?

@GetMapping

@RequestMapping

Both of them

None of the same.

Question - 20 SCORE: 5 points


SpringBoot Q6

kickoff springboot

Which ORM Spring supports ?

Hibernate

6/24
iBatis

JPA

All

Question - 21 SCORE: 5 points


SpringBoot Q2

kickoff springboot

What is true about <map> collection configuration elements?

This helps in wiring a list of values, allowing duplicates.

This helps in wiring a list of values but without any duplicates.

This can be used to inject a collection of name-value pairs where name and value can be of any type.

This tag is not supported.

Question - 22 SCORE: 2 points


SpringBoot Q3

kickoff springboot

The concept of an endpoint in web services is much like that of a controller in web applications

TRUE

FALSE

Question - 23 SCORE: 1 points


Spring boot

Spring boot MVC

Which of the following are most common object notation to interact with backend?

XML

Json

Both of them

None of them

Question - 24 SCORE: 1 points


Spring boot

Spring boot MVC

7/24
If you dont write @Service annoation, what will happen to your application. NOTE: You have used class in other @Controller file

It will work just fine

It will throw an issue on compile time

It will give a run time error

None of these option

Question - 25 SCORE: 1 points


Spring boot

Spring boot MVC

To specify a class to be a controller which annotation can you use?

@RestController

@Controller

Both of them

None of them

Question - 26 SCORE: 1 points


Spring boot

Spring boot MVC

With the help of which annotation will I be able to use to map the request to a specific end point in RESTful application?

@Request()

@Mapping()

@RequestMapping()

All of these

Question - 27 SCORE: 1 points


Spring boot

Spring boot MVC

Which of the annotation will we use when we want to annotate the class with the business logic for the application?

@RestContoller

@Controller

8/24
@Repository

@Service

Question - 28 SCORE: 1 points


Spring boot

Spring boot MVC

If I want to make a rest controller which annotation will we use?

@Repository

@Controller

@RestController

@Rest

Question - 29 SCORE: 1 points


Spring boot

Spring boot MVC

What does M in the MVC, stands for?

Model

View

Controller

None of them

Question - 30 SCORE: 2 points


MCQ18

springboot

Starting points of Spring Boot Application?

@SpringBootApplication

@RestController

@Controller

None of the Above.

Question - 31 SCORE: 2 points


MCQ2

9/24
springboot

What does the @SpringBootApplication annotation do internally?

@Configuration

@Autowired

@ComponentScan

@Configuration, @EnableAutoConfiguration, and @ComponentScan

Question - 32 SCORE: 2 points


MCQ14

springboot

Which annotation is not Spring Boot Annotation?

@PostMapping

@GetMapping

@Service

@Metadata

Question - 33 SCORE: 2 points


MCQ15

springboot

Minimum Java version needed for Spring Boot?

Java 10

Java 8

Java 7

Java 11

Question - 34 SCORE: 2 points


MCQ22

springboot

How to configure hibernate in spring boot?

Spring-boot-starter-data-hibernate

10/24
Spring-boot-starter-data-jpa

Spring-boot-starter-data-web

none of the Above.

Question - 35 SCORE: 2 points


MCQ30

springboot

Is Spring Boot is an open-source micro framework ?

FALSE

TRUE

Question - 36 SCORE: 2 points


MCQ17

springboot

Is Dependency needed to create a Spring Boot web application?

Spring-boot-starter-web

Spring-boot-starter-test

Spring-boot-html

None of the Above.

Question - 37 SCORE: 2 points


MCQ6

springboot

What is the default port of tomcat in spring boot?

8081

8080

5555

8000

Question - 38 SCORE: 2 points


MCQ1

springboot

11/24
SpringBoot has embedded tomcat, jetty which makes it just code and run the application.

TRUE

FALSE

Question - 39 SCORE: 2 points


MCQ5

springboot

Is it possible to change the port of the embedded Tomcat server in Spring Boot?

YES

NO

Question - 40 SCORE: 2 points


MCQ4

springboot

This method serves as an entry point, which invokes the SpringApplication#run method to bootstrap the application.

SpringApplication.run(MyApplication.class);

SpringApplication.start(MyApplication.class);

SpringApplication.begin(MyApplication.class);

none of the above.

Question - 41 SCORE: 2 points


MCQ3

springboot

What is the purpose of using @ComponentScan in the class files?

use for component declaration

use for autowiring

scans all the beans and package declarations when the application initializes.

scans all the classes when the application initializes.

Question - 42 SCORE: 2 points

12/24
MCQ12

springboot

Annotation used for handling GET requests?

@PostMapping

@GetMapping

@PutMapping

None of the Above.

Question - 43 SCORE: 2 points


MCQ16

springboot

Which of the following is used by Maven?

Pom.xml

Config.xml

META-INF

None of the Above.

Question - 44 SCORE: 2 points


MCQ19

springboot

Database object must be annotated with?

@Table

@Entity

@Column

@Repository

Question - 45 SCORE: 2 points


MCQ20

springboot

JPA is a Data Access Abstraction used to reduce the amount of boilerplate code

13/24
TRUE

FALSE

Question - 46 SCORE: 2 points


MCQ21

springboot

@PathVariable annotation can be used to handle template variables in the request URI mapping,

FALSE

TRUE

Question - 47 SCORE: 2 points


MCQ23

springboot

response status 404 used for

RESOURCE NOT FOUND

BAD REQUEST

UNAUTHORIZED

SERVER ERROR

Question - 48 SCORE: 2 points


MCQ24

springboot

response status 401 used for

RESOURCE NOT FOUND

BAD REQUEST

UNAUTHORIZED

SERVER ERROR

Question - 49 SCORE: 2 points


MCQ25

springboot

14/24
response status 500 used for

RESOURCE NOT FOUND

BAD REQUEST

UNAUTHORIZED

SERVER ERROR

Question - 50 SCORE: 2 points


MCQ27

springboot

In a Model Class a Columns are Annotated with

@Id

@Column

@JoinedColumn

none of the Above.

Question - 51 SCORE: 1 points


SpringBoot

easy

@SpringBootApplication
public class Application {
public static void main(String[] args) {
SpringApplication.run(Application.class, args);
}
}
For @SpringBootApplication, what is equivalent of below annotations ?

Configuration Annotation

EnableAutoConfiguration Annotation

ComponentScan Annotation

All of the above

Question - 52 SCORE: 1 points


Spring boot

JPA

15/24
Consider the following snippets and Fill in the blanks for the application

Course.java

package com.springboot.learnjpaandhibernate.model;

import jakarta.persistence.Entity;
import jakarta.persistence.Id;

@Entity
public class Course {

@Id
private int id;
private String name;
private String author;

// GETTER SETTER AND CONSTRUCTOR

SpringDataJPARepository.java (Repository for the application)

package com.springboot.learnjpaandhibernate.springdatajpa.repository;

import java.util.List;

import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;
import org.springframework.stereotype.Repository;

import com.springboot.learnjpaandhibernate.model.Course;

// Annotation for declaring the repository


public interface SpringDataJPARepository extends JpaRepository<Course, Integer> {
public List<Course> _____________________(String author);
}

you need to write a function name so that you can search based on the author i.e. author as a parameter

NOTE: You can assume everything is configured correctly.

findByAuthor

findBasedOnAuthor

getByAuthor

author

Question - 53 SCORE: 1 points


Spring boot

Annotation

Consider the following snippet and fill in the blanks for the same.
package com.springboot.restapi.repository;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.stereotype.Repository;

16/24
import com.springboot.restapi.model.HelloWorldBean;
________________
public interface HelloWorldRepository extends JpaRepository<HelloWorldBean, String> {
}

@Controller

@Service

@Repository

@Autowired

Question - 54 SCORE: 5 points


Spring boot

Web

Consider the following code and fill in the blanks

com.example.sampleapplication

@SpringBootApplication

public class SampleApplication {

public static void main(String[] args){

.... code for starting spring boot application

com.example.sampleapplication.controller

@RestController

public class StudentController {

@GetMapping("/response_entity")

public ____________________ withResponseEntity() {

int randomInt = 8;

if (randomInt < 9) {

return ResponseEntity.status(HttpStatus.EXPECTATION_FAILED).body("Value is less than 9");

} else {

return ResponseEntity.status(HttpStatus.OK).body("Value is greater than or equal to 9");

ResponseEntity<Integer>

ResponseEntity<Float>
17/24
ResponseEntity<String>

None of these are correct options

Question - 55 SCORE: 5 points


Spring boot

Web

Consider the following code. Assuming all the dependency and imports are done correctly.

com.example.sampleapplication

@SpringBootApplication

public class SampleApplication {

public static void main(String[] args){

.... code for starting spring boot application

com.example.sampleapplication.controller

@RestController

public class StudentController {

@GetMapping("/index/{id}")

public SampleModel index(@____________________ String id){

return new SampleModel(12, 12);

Consider the above example and fill in the blanks if you have a request that look like below

http://localhost:8080/index/12

RequestParam

PathVariable

ModelAttribute

RequestBody

Question - 56 SCORE: 5 points


Spring boot

Web

18/24
Consider the following code. Assuming all the dependency and imports are done correctly.

com.example.sampleapplication

@SpringBootApplication

public class SampleApplication {

public static void main(String[] args){

.... code for starting spring boot application

com.example.sampleapplication.controller

@RestController

public class StudentController {

@GetMapping("/index")

public SampleModel index(@____________________ String id){

return new SampleModel(12, 12);

Consider the above example and fill in the blanks if you have a request that look like below

http://localhost:8080/index?id=12

RequestParam

PathVariable

ModelAttribute

RequestBody

Question - 57 SCORE: 1 points


Spring boot

Annotation

Consider the following code snippet and fill in the blanks

// Controller

@RestController // this is the controller for the spring boot application


public class SampleController {

// logic for sample controller

_____________________ // this is the service file for the spring boot application
19/24
public class SampleService {

// logic for sample service file logic for database

@Entity // this is the entity class for the application


public class Sample {

// logic for sample model object

@Service

@Autowired

@Component

@Repository

Question - 58 SCORE: 5 points


Spring boot

Web

Consider the following code and predict the behaviour for the program. You can assume all the things imports and
dependency are done correctly.

com.example.sampleapplication

@SpringBootApplication

public class SampleApplication {

public static void main(String[] args){

.... code for starting spring boot application

com.example.sampleapplication.controller

@RestController

public class StudentController {

@GetMapping("/index")

public String index(){

return "index";

NOTE: folder where i will be keeping the jsp files

index.jsp

<h1>Index page is rendered here</h1>


20/24
Consider the above code and predict the behaviour for the application on the browser.

It will redirect to index.jsp page

This will throw you an error because it is not able to find the JSP file.

{"key": "index"}

index

Question - 59 SCORE: 5 points


Spring boot

Web

Consider the following code and predict the behaviour for the program. You can assume all the things imports and
dependency are done correctly.

com.example.sampleapplication

@SpringBootApplication

public class SampleApplication {

public static void main(String[] args){

.... code for starting spring boot application

com.example.sampleapplication.controller

@Controller

public class StudentController {

@GetMapping("/index")

public String index(){

return "index";

NOTE: folder where i will be keeping the jsp files

index.jsp

<h1>Index page is rendered here</h1>

Consider the above code and predict the behaviour for the application on the browser.

It will redirect to index.jsp page

This will throw you an error because it is not able to find the JSP file.

{"key": "index"}
21/24
index

Question - 60 SCORE: 5 points


Spring boot

Web

Consider the following code. Assuming all the dependency and imports are done correctly.

com.example.sampleapplication

@SpringBootApplication

public class SampleApplication {

public static void main(String[] args){

.... code for starting spring boot application

com.example.sampleapplication.controller

@RestController

public class StudentController {

@GetMapping("/index")

public SampleModel index(){

return new SampleModel(24, 12);

com.example.sampleapplication.model

public class SampleModel{

private int number1;

private int number2;

public SampleModel(int number1, int number2) {

super();

this.number1 = number1;

this.number2 = number2;

public int getNumber1() {

return number1;

public void setNumber1(int number1) {

this.number1 = number1;
22/24
}

public int getNumber2() {

return number2;

public void setNumber2(int number2) {

this.number2 = number2;

Predict the behaviour for the above code on browser.

{"number1":24,"number2":12}

number1: 24
Number2: 12

{"number1":12,"number2":24}

None of these will be used

Question - 61 SCORE: 5 points


Spring boot

Annotation

Consider the following coding structure and Fill in the details for the application

com.example.sampleapplication

@SpringBootApplication

public class SampleApplication {

public static void main(String[] args){

.... code for starting spring boot application

com.example.sampleapplication.controller

@RestController

public class StudentController {

@___________________

23/24
private SampleModelService sampleModelService;

@GetMapping("/index")

public SampleModel index(){

// Some method from SampleModelService

return output;

com.example.sampleapplication.model

// Code to declare this class as a table

public class SampleModel{

// code for model class

com.example.sampleapplication.dao

// annotation used to declare a dao class

public interface SampleModelDAO extends {{JPA Repository name}}{

// code for DAO class

com.example.sampleapplication.service

// annotation used to declare a service class

public interface SampleModelService extends {{JPA Repository name}}{

// code for service class

Assuming import and dependency are done properly, Please fill in the blanks for the same.

Autowired

Service

Repository

Entity

24/24

You might also like