wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Content Section

Total questions: 99

Worksheet time: 50mins

Name
Class
Date
1.

Which file is the default configuration?

a)

application.properties (or .yml)

b)

config.xml

c)

web.xml

d)

main.java

2.

YAML format relies on…

a)

Indentation/Spacing

b)

Semicolons ;

c)

Braces {}

d)

Tags <>

3.

@PropertySource is used to…

a)

Define variable

b)

Read XML

c)

Load custom .properties file

d)

Load YAML

4.

@Transactional on private method?

a)

Works if reflected

b)

Works fine

c)

Ignored (Proxies need public accessibility)

d)

Throws Exception

5.

Checked Exceptions trigger rollback by default?

a)

Always

b)

No

c)

Maybe

d)

Yes

6.

DTO pattern helps to…

a)

Slow down mapping

b)

Add complexity

c)

Connect to DB

d)

Decouple API contract from Internal Domain Model

7.

Default rollback behavior of @Transactional?

a)

Rollback on Checked Exception

b)

No rollback

c)

Rollback on Exception

d)

Rollback on RuntimeException only

8.

How to rollback on Checked Exception?

a)

rollback=true

b)

rollbackFor = Exception.class

c)

catch exception

d)

throw new RuntimeException

9.

Propagation.REQUIRED means?

a)

Create new transaction always

b)

Throw error if no transaction

c)

Run without transaction

d)

Join existing or create new

10.

Propagation.REQUIRES_NEW means?

a)

Start a new transaction and suspend any existing one

b)

Join an existing transaction if present

c)

Run without any transaction, never create one

d)

Use the outer transaction and nest operations inside it

11.

Self-invocation of @Transactional method?

a)

Transaction ignored (Bypasses proxy)

b)

Rolls back

c)

Starts new transaction

d)

Starts transaction

12.

Service methods should be…

a)

Depending on HttpServletRequest

b)

Depending on UI

c)

Stateless

d)

Stateful

13.

The Service Layer is responsible for…

a)

Rendering HTML

b)

Handling HTTP requests

c)

Business Logic & Transaction boundaries

d)

Saving to DB directly

14.

Using MapStruct or ModelMapper avoids…

a)

Boilerplate manual mapping code

b)

Errors

c)

Compilation

d)

Writing code

15.

What is ACID?

a)

Database brand

b)

Atomicity, Consistency, Isolation, Durability

c)

A drug

d)

Async, Code, Inversion, Data

16.

What is Idempotency?

a)

Operation is fast

b)

Operation runs once

c)

Multiple identical requests same effect

d)

Operation fails twice

17.

What is Isolation Level?

a)

Thread isolation

b)

Degree transaction sees changes from another

c)

Server isolation

d)

Network isolation

18.

What is a Dirty Read?

a)

Reading uncommitted changes from another transaction

b)

Reading old data

c)

Reading corrupt file

d)

Reading null

19.

What is a Fat Controller (Bad Practice)?

a)

Controller containing Business Logic

b)

Controller with too many dependencies

c)

Controller with large fonts

d)

Large file size

20.

Where should mapping (Entity <-> DTO) happen?

a)

Inside Controller

b)

Inside Service or dedicated Mapper

c)

Inside Database

d)

Inside View

21.

@RequestBody does what?

a)

Deserializes HTTP request body to Java object

b)

Returns body

c)

Serializes object

d)

Validates body

22.

@ResponseBody does what?

a)

Parses XML

b)

Serializes Java object to JSON in HTTP response

c)

Deletes body

d)

Reads body

23.

Annotation for URL path variable (/users/{id})?

a)

@PathVariable

b)

@Path

c)

@RequestParam

d)

@QueryParam

24.

Annotation for query params (?q=search)?

a)

@Path

b)

@Query

c)

@RequestParam

d)

@Body

25.

Best practice for REST API versioning?

a)

No versioning

b)

Change database

c)

URL path (/api/v1/...) or header

d)

Change domain

26.

Default JSON library in Spring Boot?

a)

Jackson

b)

Gson

c)

JsonB

d)

Moshi

27.

Global exception handling in REST?

a)

System.exit

b)

Try-catch in controller

c)

@ControllerAdvice + @ExceptionHandler

d)

web.xml logic

28.

HTTP 500 means?

a)

Banned

b)

Not Found

c)

Internal Server Error

d)

Client Error

29.

HTTP status 201 means?

a)

OK

b)

Created

c)

Accepted

d)

No Content

30.

HTTP 401 vs 403?

a)

401 Unauthorized, 403 Forbidden

b)

401 Forbidden, 403 NotFound

c)

401 Server Error

d)

Same

31.

How to ignore a field in JSON with Jackson?

a)

@JsonIgnore

b)

@Transient

c)

@Ignore

d)

@Expose

32.

ResponseEntity allows you to…

a)

Log errors

b)

Customize Status Code, Headers, and Body

c)

Send email

d)

Connect DB

33.

What does REST stand for?

a)

Renewable Energy System

b)

Real State Transfer

c)

Representational State Transfer

d)

Remote Execution Standard

34.

What is HATEOAS?

a)

HTML format

b)

A protocol

c)

A header

d)

Hypermedia as Engine of Application State

35.

Which HTTP method is IDEMPOTENT?

a)

None

b)

POST

c)

PATCH

d)

PUT (and GET, DELETE)

36.

Can Thymeleaf generate non-HTML (e.g. XML, Text)?

a)

No

b)

Only PDF

c)

Only CSS

d)

Yes

37.

Difference between Thymeleaf and React?

a)

Thymeleaf faster

b)

None

c)

React is Java

d)

Thymeleaf SSR, React CSR

38.

Escaping HTML by default causes?

a)

Slow rendering

b)

Security against XSS

c)

Errors

d)

XSS vulnerability

39.

Expression *{...} is for?

a)

Variables

b)

URLs

c)

Selection on selected object (th:object)

d)

Messages

40.

How to include a fragment?

a)

th:insert / th:replace

b)

th:get

c)

th:add

d)

th:import

41.

How to pass data from Controller to View?

a)

Session only

b)

Static variables

c)

Magic

d)

Using Model addAttribute()

42.

Is Thymeleaf compiled?

a)

Yes, cached

b)

No, interpreted

c)

No, parsed runtime

d)

Yes, like JSP

43.

Key attribute for conditional logic?

a)

th:if / th:unless

b)

th:show

c)

th:check

d)

th:when

44.

Key attribute for iteration?

a)

th:each

b)

th:while

c)

th:loop

d)

th:for

45.

Layout Dialect helps with?

a)

Database

b)

Sorting

c)

Colors

d)

Creating master page layouts

46.

Natural Templating means?

a)

HTML looks correct in browser without server

b)

It writes itself

c)

Compiles to C++

d)

Uses nature photos

47.

Syntax for URL (Link) expression?

a)

@{...}

b)

${...}

c)

*{...}

d)

...^{...}

48.

Syntax for variable expression?

a)

${...}

b)

#{...}

c)

*{...}

d)

@{...}

49.

Thymeleaf is a…

a)

JSP replacement

b)

Database

c)

JavaScript framework

d)

Java Template Engine (Server Side)

50.

Where are templates stored by default in Spring Boot?

a)

src/main/resources/templates

b)

src/html

c)

src/public

d)

src/main/webapp

51.

@PreAuthorize allows?

a)

Logging

b)

Method-level security expressions (SpEL)

c)

Transaction management

d)

Post processing

52.

Best place to store passwords?

a)

Encrypted (Reversible)

b)

Plain text

c)

Base64

d)

Hashed (BCrypt/Argon2)

53.

CORS stands for?

a)

Cross-Origin Remote Service

b)

Cross-Origin Resource Sharing

c)

Core Operating Risk System

d)

Cascading Origin Style

54.

CSRF stands for?

a)

Cross-Site Request Forgery

b)

Common Security Risk Factor

c)

Cascading Style Reference File

d)

Central Server Request Filter

55.

Core concept of Spring Security?

a)

Aspect

b)

Filter Chain

c)

Controller

d)

Interceptor

56.

Default login form comes from?

a)

Thymeleaf

b)

Cannot have login form

c)

Auto-generated by Spring Security

d)

Windows

57.

Difference between hasRole and hasAuthority?

a)

Role is deprecated

b)

Role adds 'ROLE_' prefix automatically

c)

Authority adds prefix

d)

No difference

58.

How many filter chains can you have?

a)

Multiple, matched by URL pattern

b)

Exactly 2

c)

Only 1

d)

None

59.

How to load users from DB?

a)

Implement UserDetailsService

b)

Use JDBC directly

c)

Hardcode in xml

d)

Use InMemoryUserDetailsManager

60.

JWT (JSON Web Token) is?

a)

Stateful session

b)

Stateless, self-contained token for auth

c)

Database key

d)

Encrypted cookie

61.

SecurityContextHolder stores?

a)

Passwords

b)

Database config

c)

Authentication of the current thread

d)

Cookies

62.

What interface represents the User?

a)

User

b)

Account

c)

UserDetails

d)

Principal

63.

What is OncePerRequestFilter?

a)

Filter that runs twice

b)

Standard Servlet Filter

c)

Base class ensuring execution once per dispatch

d)

Interceptor

64.

What manages Authentication?

a)

SecurityContext

b)

AccessDecisionManager

c)

UserDetails

d)

AuthenticationManager

65.

Why disable CSRF for REST APIs?

a)

Because REST APIs are stateless/non-browser based usually

b)

Because Browsers handle it

c)

To be faster

d)

Never disable it

66.

@Email validates what?

a)

String structure (Regex)

b)

Email existence

c)

Spam check

d)

DNS record

67.

@NotEmpty vs @NotBlank?

a)

Same

b)

NotBlank checks for spaces only

c)

NotEmpty checks size>0, NotBlank checks trimmed length>0

d)

NotEmpty is Collection only

68.

@Pattern uses?

a)

SQL

b)

Java code

c)

Glob

d)

Regular Expression (Regex)

69.

@Size is for?

a)

Integers only

b)

Strings, Collections, Arrays

c)

Objects

d)

Files

70.

Annotation to check for null?

a)

@CheckNull

b)

@NotNull

c)

@Null

d)

@Exists

71.

Can validation messages be internationalized?

a)

Only in English

b)

Yes, usually via ValidationMessages.properties

c)

Yes but hard

d)

No

72.

Can you validate Service method parameters?

a)

Yes, using @Validated on class

b)

No

c)

Yes, manually

d)

No, only Controllers

73.

Custom validation requires extending?

a)

ValidatorBase

b)

ValidationManager

c)

CustomChecker

d)

ConstraintValidator

74.

Standard for Validation in Java?

a)

JUnit

b)

Bean Validation (JSR-380/Hibernate Validator)

c)

Log4j

d)

Spring Validator

75.

Validating recursive objects (nested DTOs)?

a)

Use @DeepValid

b)

Not possible

c)

Add @Valid to the field

d)

Automatic

76.

Validation groups are for?

a)

Grouping errors

b)

Performance

c)

Grouping users

d)

Applying partial validation (e.g., Create vs Update)

77.

What does @AssertTrue do?

a)

Checks if String is 'true'

b)

Asserts in test

c)

Nothing

d)

Checks if boolean field/method returns true

78.

What object captures validation errors in Controller?

a)

Model

b)

ErrorList

c)

Exception

d)

BindingResult

79.

Where to put @Valid in Controller?

a)

Inside the DTO

b)

On Return type

c)

On Method

d)

Before the @RequestBody parameter

80.

API Documentation tool?

a)

Javadoc

b)

Swagger / OpenAPI

c)

Word

d)

Excel

81.

CI/CD stands for?

a)

Code Integration / Code Deployment

b)

Compile Immediately / Compile Daily

c)

Computer Interface / Computer Design

d)

Continuous Integration / Continuous Deployment

82.

Containerization tool?

a)

VMware

b)

VirtualBox

c)

Zip

d)

Docker

83.

DTO vs Entity separation avoids?

a)

Over-exposing DB structure and LazyInitializationExceptions

b)

Good design

c)

Security

d)

Performance

84.

Database migrations tool?

a)

Flyway or Liquibase

b)

Manual SQL

c)

Hibernate HBM2DDL only

d)

Backup/Restore

85.

Deploying Spring Boot app?

a)

Run the executable JAR (java -jar app.jar)

b)

Copy source code

86.

Environment specific config is done via?

a)

Different JARs

b)

Profiles

c)

Hardcoding

d)

Magic

87.

Frontend communicates with Backend via?

a)

HTTP/REST APIs

b)

Direct memory

c)

Telepathy

d)

Shared files

88.

Input checking should happen?

a)

Database only

b)

Nowhere

c)

Both Frontend (UX) and Backend (Security)

d)

Frontend only

89.

Integration Testing uses?

a)

Unit tests

b)

Manual testing

c)

MockMvc only

d)

@SpringBootTest (Loads full context)

90.

Logging framework in Spring Boot default?

a)

Log4j 1

b)

Logback (via SLF4J)

c)

System.out

d)

Java Util Logging

91.

Monitoring Spring Boot app?

a)

Ping

b)

Task Manager

c)

Spring Boot Actuator

d)

Print statements

92.

Pattern Matching for switch (Java 17+) allows?

a)

Only enums

b)

Switching on types using guarded patterns

c)

Switching databases

d)

Regex in switch

93.

Reverse Proxy example?

a)

Spring

b)

Tomcat

c)

Nginx

d)

MySQL

94.

Stateless vs Stateful backend?

a)

Stateless scales better (horizontal scaling)

b)

Stateless uses sessions

c)

No difference

d)

Stateful scales better

95.

Typical Spring Boot Layering?

a)

View -> DB

b)

Service -> View -> Controller

c)

Controller -> Service -> Repository -> Database

d)

Controller -> Repository

96.

What is a 'sealed' class (Java 15+)?

a)

Class in a JAR

b)

Encrypted class

c)

Class that restricts which other classes may extend it

d)

Class with no methods

97.

Key feature of Java 19/21 Virtual Threads (Project Loom)?

a)

Faster UI

b)

Lightweight, high-throughput concurrency

c)

Better graphics

d)

New syntax

98.

New HttpClient (Java 11) feature?

a)

Deprecated

b)

Only callback based

c)

Asynchronous and support for HTTP/2

d)

Uses XML

99.

Which Garbage Collector is designed for sub-millisecond pauses (Java 15+)?

a)

Serial

b)

ZGC (Z Garbage Collector)

c)

G1

d)

Parallel