Java, Springboot, Security, Microservices
Java, Springboot, Security, Microservices
Sections
accessed
Bill
O O O O
loadUserByUserName
LoadUserByUsermame loadUserBy
load
wanted S1
i
User
No.
and to 1
in
object the
user
Name details
that
object.
method.
He
studied
the
UserDetailsService
class
and
found
out
about
a
method
in
which
the
roles
can Time
be
Left
Question
Sections
Which
O O O
Broker Consumer Producer
S1
Scheduler
T4
1
of
assessment
the No.
following
2
is
NOT
a
component
of
event-driven
architecture?
Question
injection, Sections
T4
O O OService
O In
Interface Setter Constructor a S1
assessment
Mark Spring T4
assessment
that i
&
Next
is the
not
available
goal
Clear is
to
control
Response
is:
the
resultant
components,
hence,
the
I0C
is
being
used.
If
the
implementation
is
being
PreviouS
done
by
the
dependency
Time
Save
Lef
&
Question
execute Spring
O "/socket"):
O
registry. O
public public public public
Boot
class the
class class addHandler(new class No.
required
needs
)) WebSocketConfig
4
WebSocketConfig
WebSocketConfig
WebSocketConfig
task?
to
forward
Socket
the
implements
implements implements ( client's
TextHandler(),
public
requests
void
WebSocketConfigurer
WebSocketConfigurer
WebSocketConfigurer
register(WebSocketHandlerRegistry
"/socket"):
to
a
particular
))
endpoint
(public (
(
public public
void
for
void void whicha
registerWebSocketHandlers(WebSocket-HandlerRegistry
register(FRegistry
registerWebSocketHandlers
registry)
handler
(
registry needs
registry)
addHandler(new to
be
registered.
(
registry (WebSocketHandierRegistry
addHandler(new
Socket Which
TextHandler(), of
the
following
SocketTextHandler(),
registry)
registry)
"socket")
code
(return:}) snippets
(
can
O@ExceptionHandler(value
O@Exception(value O@ExceptionResponseHandler(value
ErrorMessage
ControllerExceptionH
Question
HtpStatus.NOT Refer
@ExceptionHandler(value
to
the No.
given
msg 5
FOUND);
= Spring
=
(ResourceNotFoundException.class,
new {
public
-
ErrorMessage(
boot
=
{ResourceNotFoundException.class,
(ResourceNotException.class,
}
Analyze
ResponseEntity<ErrorMessage>
application
the
=
(ResourceNotFoundException.class,
options
date,
handling
ex.getMessage(),
and
select
ABCException.class}) ABCException
resourceNotFoundException(ResourceNotFoundException in
the
ABCException.class}) the
code
correct
description),
snippet
class)
answer.
ABCException.class)
shown
return
alongside.
new
ResponseEntity<ErrorMessage>(msg.
Add
the
missing
line
of
ex, code@ControllerAdvicepublic
WebRequest
request)
class
O@BeanSecurity Question
used
O@BeanSecurity O@BeanSecurity
In
anyRequest(),
anyRequest().authenticated(): anyRequest(),authenticated(); anyRequest(),authenticated(); O
@BeanSecurity a
Spring
for
this? No.
application,
authenticated():
authorization
.
) )
) )
...
// // I
/.. of
return return return return HTTP
to
AuthenticationException
AuthenticationException
AuthenticationException
AuthenticationException
be
performed
and
a
Security
{ { { {
authorize authorizeRequests((authorize)
http http
Filter
authorize
authorizeRequests(authorize)
Chain
Http
Requests(authorize)
Http is
being
Requests(authorize)
declared
> here
authorize
-> ->
authorize Which
authorize
->
authorize
of
the
following
codes
can
be
Question
Oll Oll return implements Interpret
findAlByDescriptionContaining(String
Oll
missing
Oll text),
missing missing missing
s.iterator(),
and No.
Streamable<ltem>
ItemRepository
code
{
private
.map(Priced
.map(Priced: map(Priced:
in
map(Priced:
the
text) final
below
implements Streamable<Item>
snippetclass
getPrice).reduce(MMAmount:add);//
getPrice).reduce(Money.of(0),
getPrice)
getPrice)
Repository
reduce(Money.of(0),
.reduce(Money.of(0),
Item
s;
public {MAmount
<Item,
MAmount
Long>
getCost()
MAmount);//
MAmount)//
MAmount
missing
{l/ getTotal(){/
missing
{...
add)//
code missing
code
}}@RequiredArgsConstructor(staticName
missing
missing
2ltems
missing
2}
code code
findAIDescriptionContaining(String
2ltems code
code 2items
2ltems )
find(String
findAByDescriptionContaining(String
@Override
text)
public
Iterator<Produc
="of')class
text):
Itens
iterator()
{
Question
Omarks
Stu A
O
Student
OStu
Stu database
FatherName)Which
name
ld No.
table
has 8
two
tables
of
the of students
following
given
options
below:
represents
Student
the table
foreign
1fint
key Stu
of ldVarchar
the
two
tables?
Stu
nameint
marks)Student
table
2(int
Stu
ldVarchar
Stu
narneVarchar
answer. CrudRepository<Student,
Sections
O@Beanpublic O@Beanpublic O@Beanpublic
Given
Mark findByld(144)"), Palmer"), findByid(144)")) repository. @Beanpublic
repository. Palmer");
log Palmer"), repository findByld(144)");
Palmer"),; repository,
below
T4
info(" assessment
for
Review
&
Next log log log
info(" save(new info(" save(new
Student(134, Student(134, info(" Student(134,
save(new save(new
Student(134,
Long>
interface
Clear {List<Student>
")
Student(164, Student(164, Student(164, Student(164,
Response
"Chloe "Chloe "Chloe "Chloe for
demo(StudentRepository
demo(StudentRepository
log demo(StudentRepository demo(StudentRepository
info(Student.
the
O'Brian")), O'Brian"),
'Student'
O'Brian"), O'Brian"),
-) )
toString();
-) entity
log repository
log.
repository repository
log
repository.save(new
String),
method
Student(144, Student(144, Student(144,
( {return
Student(144,
Student Student ( Student Student (
return return )
return
Student using
log log. log.
info(")
=
repository
(args)
info(")
= ()
->{repository
=
findByld(144),
(args)
info(")
= (args)
repository.findByld(144),
repository
commandline
{ (repository
repository } Bauer"),
(repository
} Bauer")),
Bauer"), Bauer")),
findByld( findByld(Jack);,
save
log
repository repository repository id),}Analyze
repository
save(new info("Student
(new save(new save(new runner.public
144),
log log
Student(123,
info("Student
save(new
Student(123, info("Student
save(new
save(new
Student(123,
log save(new
Student(123,
found
info("Studert
the interface
given
options
found "Jack found "Jack "Jack
findByld( StudentRepository
Bauer") found
Previous
Bauer")
with with Bauer") Bauer"). and
"David "David
"David "David
144)"); with
select
the
Save extends Time
correct
Left:1
&
Ne
Question
defines body SongNotFoundException ResponseEntityExcepionHandler
Given 4
Mark
O
public
Opublic
O
%s id)), found", public
id), public
put("'message",
S1
not ) }) below
for
cass
the No.
found"
class class class
Review
id), 'SongNotFoundException'
is 10
SongNotFoundException SongNotFoundException
) SongNotFoundEXception SongNotFoundException
the
& id)), exception
Next "Song
}}
ex,
not WebRequest
handler
found");
Clear
{@ExceptionHandler(SongNotFoundException.class)
Response implementation
class
return
extends extends extends extends
request)
that
new
displays
Exception RuntimeException
ControllerAdviceException
RuntimeException ResponseEntity<>(body,
(Map<String,
for
the the
(
sutable music
public
Object>
app.@ControllerAdvicepublic
CityNotFoundException(Long
( (
exception
public public
body
CityNotFoundException(Long
( CityNotFoundException(Long
HttpStatus
public
message?
=
new
CityNotFoundExXception(Long
LinkedHashMap<>0,
NOT public
FOUND),
ResponseEntity<Object>
class
id)
(
super(String
JHow ControllerAdvisor
id) id)
( (String
body
super(String
would
id) format("Song
put(
(super(String
format("Song
you
timestanmp",
define extends
handile
format("Song
the Song
with
format(Song corresponding LocallDate
Previous
with NotfoundException(
title
title
with
%s
not title 65 Time
found not
with class
now():
Save 6s found
res
=
new
-A.getA(),
=
new
getA(): No.
11
A(), getA).
Lookup
is
an
approach
where
we
get
the
resource
after
demand.
Select
the
correct
method
to
get
a
resource
of
Dependency
Lookup
Time
L
Question
Employee),
class Refer
O
O@RequestMapping(value O@RequestMapping(value
ResponseEntity
emp @RequestMapping(value
emp emp.get(unit), emp.getUnit();
@RequestMapping(value
EmployeeController
setUnit("RCL"), setUnit("RCL"),
to
the No.
emp.setName("Franklin"),
given
12
accepted().
var var code
empHeaders
empHeaders
empHeaders empHeaders
headers(empHeaders)
getEmp")public
=
"getEmployee")public
="getEmployee")public ="getEmployee")public
in
spring
=new =
new
emp.setUnit("RCL"),
CODE boot.
= HtpHeaders(),
HttpHeaders();
new new
@RequestMapping(value
Find
HttpHeaders(); HttpHeaders(),
ResponseEntity<Employee>
the
body(emp);) ResponseEntity<Employee> ResponseEntity<Employee> ResponseEntity<Employee> missing
empHeaders empHeaders.
return
code
empHeaders empHeaders.
emp,
which
add add.body();
}} =
"IgetEmployee")
will
body();
add("Created",
Define
add getEmp()
("Created"
the
(var Response
empHeaders.ResponseEntity
ResponseEntity. @ResponseBody
emp
"EmployeeController"); "EmployeeController"),
accepted()) Response
setName(Franklin")
empHeaders)
getEmployee)
sethName("Franklin")
get(Name) getName():
code
(
body(emp),)
var
@Controllerpublic
emp
=
new
Question
Select
O O O
public public public public
the
class class class class No.
Spring
has
@Autowired('worker1") an
@ annotation
Setter('worker1")
@Bean("worker1")
@Qualifier('worker
for
holding
private
Worker private
Worker
Worker
of
comparable
worker:)
Worker
worker:)
worker:)
worker)
types
The
dependency
injection
must
be
used
correctly
in
the
code.
Question
O OLine
O O
Igr.log(Level.
1+1))
(7. java Consider
SQLEXCeption;3.
No.
if the
SEVERE,
(rs.next()
following
14
ex {12.
import
code
getMessage(),
System.
for
try connecting
java.
(var
out.printin(rs
con=DriverManager
util.
ex);17. logging.Level,4.
to
the
}18. getlnt(1); in-memory
)19.)
import
13. getConnection(url);
database.
}14.
java.util.
catch
Which
logging.Logger,5.
(SQLException
9. line
var contains
stm
ex)
= public
con.createStatement();
an
(15. error
class
var
here?1.
lgr Java
=
Logger import
H2
Mermory
get(JavaSet2Mermory
10 java
var
sql
rs (6. DriverManager,2.
public
=
stmt
executeQuery("SELECT static
void
ciass
import
main(Stringl]
getName));
args)
16.
position Question
O
Producer
O
Producer
O
Event
Martin
Producer
read
bus, of No.
microservices,
microservices, two
about
microservices,
Producer
15
of
the event-driven
steps
microservices,
Consumer
Consumer involved.
Event
architecture
bus,
Choose
microservices
microservices,
Consumer Consumer
and
the
listed
microservices microservices option
Event
out
with
the
bus the steps
correct
involved
order
of in
it
the in
steps. their
respective
order.
Due
to
certain
misunderstandings,
he
interchanged
the
O@Componentpublic O@Componentpublic
O@Componentpublic O@Componentpublic must
A
event) event) Event<String>
event) code
be
(System.out, {System
is
(
System. to
be
written
event)
out. out
printin("Print class printin("Print
class
printin("Print
class in
class
(
System
a
Spring
demoListener
demoListener
demoListener demoListener
Data'");
out, application
Data") Data");
println("Print
)) (
@EventCondition(condition
)) (@EventListener(condition
})
(@EventConditional(condition
(
@EventConditionalListener(condition
where
Data")
the
event
}}
listener
= = used
"#event.
"#event
=
"#event is
to
success")
success")
be
= made
success") "#event
Conditional.
public
public success")
public
void
void
void
handle public It
handle must
handle
Successful(Generic
void run
Successful(Genenc
Successful(Geneic
handle only
upon
Successful(
the
success
Spring
Spring
Spring Generic
Event<String
Event<String of
an
Event<String
Spring event
The
code
O@Scheduler(fixedDelay Question
fixed
@Scheduled(fixedDelay
O
O@Scheduler(fixedDelay
A
Spring
1000 1000 @Scheduled(fixedDelay
1000, 1000
delay
System.out
System.out, System.out
System.out
developer
No.
of
4
seconds.
17
wants
printn( printin("Time printin("Time
printin("Time
Which
"Time =
4000,
= = = to
4000, 4000, 4000, write
code
now-"+
initialDelay
now-"
startDelay
now-"+now);)
initialDelay now-" startDelay
a
code
should
now):) now):)
+ to
schedule
now):)
= = = = he
2000)public
2000)public 2000)public
2000)public
use?
the
tasks
schedule schedule
in
schedule schedule
the
system.
The
Delay Delay
Delay Delay have
Task)
Task(0 Task() Task() a
starting
{
( ( (
long long long
long
delay
now now
now now
= of
= = = 2
System
System. System System seconds
current
currentTimelillis()/
currentTimeMilis)
curent
and
later
TimeMillis)
TimelMillis()
there
must
/
/
be
a
O@GetMapping("products1")@Responsepublic
O@GetMapping("/products1")@Responsepublic
O@GetMapping("products
to
the No.
add("Created"
add("Responded",
piece
retun
add(new
"ProductionController"),
add(new
1")@Responsepublic
1")@ResponseBodypublic
"Cookie")
Product(2,"Tony"), Find
prodBody:)
Product(2, Product(2,"Tony"),
the
missing
products
"ProductController");
"Tony")
public code
List<
List List< add(new
return prods.
piece
Product>
< ResponseEntity
Product
prods. prods
products10(
products1()
> return
will
products
Product(3,
List<
Product(3,
10 "Tom"),
the
{List Product(3, { Product
var List
products.add(new
response
prodBody
<Product
< (
Product> List
return
>>
"Tom"), "Tom")
< products) body
Product>
prods)
= >
new prods
for
Body) prods Body), Product(3,
given
{
HttpHeaders():
=
var new return
=
new
prods= List
response
prodBody
<
"Butter"),
Product
ArayList
ArrayList
prods) new
header
ArrayList
prodBody
>
=
new <> <> HttpHeaders
products
in
Hitp-Headers).
0. 0:
<> the
add("Created"
prods.
prods
= code
0: new
add(new prods
add(new respHeader
@RestControllerpublic
ArrayList
)
add(new //MISSING
Product(1,
Product(1.
= <>
Product(1 new
0
CODE)
class
Question
help Which
INF/Views/") resolver
of
a
resolver?
of No.
setPrefix("WEB-INFiviews/"),
the
get("/WEB-INF/Views/"),
following
19
resolver.get("
(
InternalResourceViewResolver
code
jsp"),
( (ResourceViewResolver (InternalResourceViewResolver
ResourceViewResolver
return resolver.
in
resolver.
the
resolver.
resolver,
options
get("
"com.ecomm.controller
setSuffix(" jsp"),
)}
setSuffix("
resolver can
return
resolver resolver= be
"com "com.
used
jsp")
jsp"),
=
resolver, new
ecomm.controller
ecomm.
return = resolver
to
return InternalResourceViewResolver(); configure
new new
"))public ResourceViewResolver(cnt),
*
}) controller."
resolver ResourceViewResolver(cnt);
=new resolver,
)public
a
spring
InternalResourceViewResolver(cnt),
}) class * }}
class })public })public
boot
AppConfig
AppConfig(@Bean
application
class class
AppConfig
AppConfig
{@Bean
resolver
resolver resolver
to
set
protected
public
{ setViewClass(JstiView (
the
setViewClass(JstView.class)
get(JstView
@Bean @Bean
view
ResourceViewResolver
resolver
prefix
ResourceViewResolver
public public
class) InternalResourceViewResolver
InternalResourceViewResolver
and
get(JstiView
suffix
resolver
class)
for
the
get("WEB
class)
application
with
the
Question
O@GetMapping("user/data")public
used
In
O@GetMapping("user/data")public
principal
Hashtable<String,
principal Hashtable<String,
principal Hashtable<String,
O
@GetMapping("user/data")public
principal Hashtable<String, QGetMapping("user/data")public a
Spring
as
the No.
getClaimAsString('company"), application,
getClaimAsString("company"), controller?
20
getClaimAsString("company")
getClaimAs
String("company"),
for
security,
put('user_name",
server
put('user_name", put(user_name", put('user_name"
Map<String, Map<String, Map<String,
Map<String,
claims
return return return return
getUserdata(@AuthenticationPrincipal
getUserdata(@AuthenticationAccess getUserdata(@AuthenticationAccessPrincipal
getUserdata(@AuthenticationPrincipalAccess
unmodifiableMap(map).)
unmodifiableMap(map)) unmodifiableMap(map), unmodifiableMap(map).)
getClaimAsString('preferred_record"),
getClaimAsString("preferred
getClaimAsString('preferred_record"),
getClaimAsString("preferred_record"),
to
be
authenticated.
These
claims
record"),
Jwt are
Jwt
principal)
principal)
to
map map. map map be
Jwt Jwt accessed
put('company", put("company
put('company put(°company"
principal) princpal)
(
( Map<String,
Map<String.
in
(Map<String,
( the
Map<String,
resource
String
String
server
map String String
map
new Which
new map map
a code
new new
must
be
Question
O
O
SignAlgorthm O
JwtAlgorithm
HS256AIgorithm While
SignatureAlgorithm
working
No.
with
21
the
JWT,
Tessa
was
looking
for
an
algorithm
to
sign
the
JETs
with.
Which
algornthm's
variations
are
provided
by
Spring
Boot?
Question
cannot
O
OInitialRate
InitialDelay
FaxedDelay O
FixedRate
Gill
wanted
be No.
used
to
define
22
to
do
the the
required number
task? of
times
method
should
execute
while
the
application
is
running
Which
of
the
following
properties
of
the
concemed
annotation
Question
O@Scheduled(cron
requirement
Suzie
O
O@Scheduled(cron
@Scheduled(cron
@Scheduled(cron
wants
No.
to
develop
23
="1"9
="0 = =
"MON
"0 a
scheduling
*9 *9**
"0 "MON
*9
*7")
MON")
"0
*") *
app
2")
in
Spring
Boot
and
schedule
a
task
every
Monday
at
9
AM.
Select
the
correct
fomat
that
she
should
use
for
her
(@ldprivate
O
@Entitypublic
(@ldprivate
O@Entitypublic
(@ldprivate
O@Entitypublic
Which
Question
{@ldprivate @Entitypublic
of
the No.
following
int 24
int int int
class buildingNo, class class
building buildingNo,
buildingNo, class
officeRecord
officeRecord
officeRecord officeRecord
codes
No,@OneToMany
@OneToOne(mappedBy="building
indicates
@One
@One
a
OneToMany
(mappedBy="building
officeNo
bidirectional
@ManyToOneprivate @ManyToManyprivate
record")private
record")private
record")private
record")private association
To
Oneprivate
correctly?
List List
List building building List
building building
office ofice
office office
Record) Record:}
Record:) Record Record
Record.)
Record Record
building building
building building
record record:}@Entitypublic
record record:}@Entitypublic
)@Entitypublic
@Entitypublic
buildingRecord buildingRecord
buildingRecord
buildingRecord
Question
O O O
MVC
Which
AOP Spring O
Annotations
(Aspect
of
Security
the No.
following
25
Oriented
parts
Programming)
of
Spring
Boot
is
related
to
the
concept
of
Authentication?
OOretun
O
Question
OOreturn
ResponseEntity
the inputAge)
Refer
ResponseEntity ("Your )return getStatus(inputAge),
0return corresponding
to
ResponseEntity
ResponseEntity.created(inputAge).
status
new {
the No.
new
if following
(isNotinLimits(inputAge))
ResponseEntity<string>(inputAge)(
26
is"
ResponseEntity<>("The
get(inputAge). created(inputAge)
status
+
getStatus(inputAge),
piece
HttpStatus.
codes.
get(inputAge).
of
code
message
OK);
responseHeader("HttpStatus",
in
{/IMISSING Spring
("HttpStatus",
message("Http
Input
HttpStatus.
responseHeader("HttpStatus"
boot
Age
application::@GetMapping("/inputAge")ResponseEntity<String>
"The is CODE
200): not
200),
Status",
Input
in
body( a 1}
desired /MISSING
Age
404),
"Your
200), is
body("The
not limit",
status body(
in CODE
HttpStatus
404). a
desired
"Your
is" Input
body
2)Find
+getStatus(inputAge):
status limit",
Age (" BAD_REQUEST);
The
the
is missing
not
is" Input HttpStatus
+getStatus(inputAge):
in
Age codes
a
desired
is 404).
(@)return
not to
()returm
check
limit):()retun
in
a
inputAge(
desired
new if
new the
ResponseEntityc>
limit")()return input
ResponseEntity<string>(inputAge)
@RequestParam(inputAge")
is
within
the
desired
Your
status limits
is+ and
int
print
Question
database
O
@ O
O
During
spring spring
spring spring
a
transaction
No.
h2 h2 h2 h2
property
setings
settings.trace-truespring
trace=falsespring
in
a
Spring
settings.trace=falsespring. that
trace=falsespring
support
bot
application,
h2.settings
the
analysis
h2.console
h2.console
one
web-allow-others-false
h2.debug.console.
of of
this the
settings transaction operations
settings
web-allow-others=ture
web-allow-others-false
error? fails
settings.web-allow-others=false
Analyze
to
execute.
the The
given
app
developer
options
and
wants
select
to
the debug
correct
this
answer issue
Which
are
the
corect
H2
Question
O@Beanpublic O@Beanpublic O@Beanpublic O@Beanpublic
Which
Spring
No.
code 28
Class Class Class
Class segment
be
utilized
(Class {
(Class (Class
Class
= = =new =
new new new
the
setterltem(demoClass
demoClass demoClass.
demoClass=setltem(item1()),
given
possibilities?
settem(item setterltem(item1()),
item1(),
10);,
retun
return
return return
demo
demo
demo demo
Class)
Class)
Class) Class)
Question
QEnatbleWebSocket
file
couldn't
of No.
the
Socket
application execute 29
the
to WebSockets
make
the
web
properly
sockets
despite
executable?
adding
the
proper
WebSocket
dependency.
Which
of
the
following
annotations
must
be
included
in
the
Question
Dan
O O
RoleGrantedAuthorty
O
GrantedAuthority
SimpleGrantedAuthority
SimpleRoleGrantedAuthoriry
wanted
No.
to 30
store
the
strings
representing
the
authorities
of
the
user
in
a
predefined
Java
class
Which
of
the
following
classes
can
help
hirm
do
so?