Spring Associate Certification MCQs


Hello friends if you are looking for Spring Associate Certification Infosys MCQs with Answers | Infosys Spring Associate Certification Objective type questions | Infy Spring Associate Certification Objective Question with Answers | Spring Associate Certification Multiple Choice Questions with Answers | Spring Associate Certification Questions and Answers then you will get here.

Click Here to Join Our Telegram Channel For More Infosys Question Answers

1.Assumption: All necessary imports are done.
oC
oD
oB
o ConcurrentModificationException exception will be thrown.

Ans – ConcurrentModificationException exception will be thrown.

2. Assumption: All necessary imports are done.
o 101- Blowing with the wind
102 – Stand by Me
Null – Annie’s Song
104 – Here I Am
o 101- Blowing with the wind
102 – Stand by Me
o NullPointerException exception will be thrown
o Null – Annie’s Song
101- Blowing with the wind
102 – Stand by Me
104 – Here I Am

Ans = NullPointerException exception will be thrown

3.Assuming the below code executes in the main method. What will be the
output of following code?

o 2013-03-02
o 2013-02-28
o 2013-03-01
o Error: Cannot add month

Ans – 2013-02-28

Note: Assume the required Imports are added.
o Peter 1001
o Jack 1002
o Jack Peter
o Jack Peter 1002

Ans – Jack 1002

Assuming the below code executes in the main method. What will be the
output of following code?

o 2021-09-09
o 2022-08-09
o 2022-09-09
o 2022-08-02

Ans – 2022-08-09

Assumption: All necessary imports are done
o [5000.0,56001.4]
o [28000.7]
o [2500.0,28000.7]
o IllegalStateException exceptionwill be thrown

Ans – IllegalStateException exceptionwill be thrown

Assumption: All necessary imports are done
o SATURDAY
o SUNDAY
o DateTimeException exception is thrown.
o IndexOutOfBoundsException exceptionis thrown.

Ans – SUNDAY

Note: Assume the required imports are added.
o {1002 = Annie}
o {1002 = Annie, 1010=joey}
o Error: ArrayIndexOutOfBounds Exception
o {1001=Chandler,1002 = Annie}

Ans – {1002 = Annie, 1010=joey}

Assumption: All necessary imports are done
o {null = null, A= Avan, B= Bob, C= Catlyn}
o {A= Avan, B= Bob, C=Catlyn}
o The code will throw run time exception as the same key cannot be
used for 2 values
o The code will throw NullPointerException as the HashMap cannot have
null as key value.

Ans – {null = null, A= Avan, B= Bob, C= Catlyn}

Assumption: All necessary configuration imports are done
o 9:45:59
o 9:59:45
o 09:45:59
o 09:59:45

Ans – o 9:59:45

What will be the output of the code given below? Note: Consider all necessary imports are added.
o Time – 23:03:15
o Time – 00:03:15
o Time – 23:58:15
o Time – 22:58:15

Ans – Time – 23:58:15

Note: Consider all necessary imports are added.
o {Spring = 0, Java = 50, spring =20}
o { Java = 50, spring =10, spring=20}
o {Java = 20, Spring =10, spring =20}
o {Java =50, spring =20}

Ans – {Java =50, spring =20}

Assumption: All necessary imports are done
o Assertions.assertEquals(true, citizen.isVoter(18))
o Assertions.assertFalse(citizen.isVoter(18))
o Assertions.assertTrue(citizen.isVoter(17))
o Assertions.assertFalse(citizen,isVoter(17))

Ans – Assertions.assertEquals(true, citizen.isVoter(18)),Assertions.assertFalse(citizen,isVoter(17))

Choose TWO correct options.
o @RequestMapping(“/students/{studentId}”),method=RequestMethod.GET)
public void getDetails(@PathVariable String studentId)()
o @GetMapping(“/students/{studentId}”)
public void getDetails(@PathVariable String studentId)()
o @RequestMapping(“/students”)
public void getDetails(@RequestParam String studentId)()
o @RequestMapping(“/students”)
public void getDetails(@PathVariable String studentId)()

Ans – o @RequestMapping(“/students/{studentId}”),method=RequestMethod.GET)
public void getDetails(@PathVariable String studentId)()
o @GetMapping(“/students/{studentId}”)
public void getDetails(@PathVariable String studentId)()

What will be the output?
o It will delete student with studentId=2002 from STUDENT table and then
throw EmptyResultDataAccessException
o It will delete student with studentId=2002 from STUDENT table and batch
with batch_id =1002 from BATCH table
o It will delete student with batch_id=1002 from BATCH table then throw
EmptyResultDataAccessException
o It will throw EmptyResultDataAccessException

Ans – o It will delete student with batch_id=1002 from BATCH table then throw
EmptyResultDataAccessException

What will be the output?
o True
o False
o illegalStateException will be thrown
o Service.CANNOT_BOOK_TICKET

Ans – true

Choose Options.
o @Query(“select p form Product p where p.manufactureedDate > ”)
List findByDate(LocateDate date)
o @Query(“select p form Product p where p.manufactureedDate > :mdate ”)
List findByDate(LocateDate date)
o @Query(“select p form Product p where p.manufactureedDate> mdate ”)
List findByDate(@Param(“mdate”) LocalDate mdate)
o List findByManufacturedDateAfter(LocateDate date)

Ans – o @Query(“select p form Product p where p.manufactureedDate > ”)
List findByDate(LocateDate date)

o @Query(“select p form Product p where p.manufactureedDate> mdate ”)
List findByDate(@Param(“mdate”) LocalDate mdate)
o List findByManufacturedDateAfter(LocateDate date)

Choose an option.
o Order placed successfully
o Code will run but nothing will be displayed
o NoSuchBeanDefinitionException exception will be thrown
o None of the options

Ans – NoSuchBeanDefinitionException exception will be thrown

Choose from the below options to execute the test cases successfully
o assertThrows, assertEquals
o assertNotEquals, assertThrows
o assertTrue, assertThrows
o assertThrows, assertFalse

Ans – assertThrows, assertEquals

What will be the value of pat_id in ig_gen table after….
o 110
o 117
o 103
o 115

Ans – 103

What will be the output.
o Loan deleted Successfully for : 1001
o Null
o illegalStateException will be thrown
o Loan deleted Successfully for: null


ANs – illegalStateException will be thrown

Output?
o String url = “http://localhost:5555/citizens/citizenType”;
o String url = “http://localhost:5555/{citizenType}”;
o String url = “http://localhost:5555/citizens/{citizenType}”;
o String url = “/citizens/{citizenType}”;

Ans – String url = “http://localhost:5555/citizens/{citizenType}”;

All the necessary imports and configurations are done.
o @Querty should be used instead of @NamedQuery
o The value of nature attribute in @NamedQuery is correct
o In repository @Param annotations is not required
o The value of name attribute in @NamedQuery is incorrect

Ans – o @Querty should be used instead of @NamedQuery,o In repository @Param annotations is not required

Which Bean validation….
Ans – Line1: @Min(value = 10000) @Max(value = 99999)
Line2: @Pattern(regex = “[a-z][A-Z]+”)
Line3: @Past
Line4: @NotNull –

What will be the following HHTP GET request can be handled by the above
controller?

o http://localhost:1111/api/events/venue=C4-Hall
o http://localhost:1111/events/venue=C4-Hall
o http://localhost:1111/events/C4-Hall
o http://localhost:1111/api/events/C4-Hall

Ans – o http://localhost:1111/api/events/C4-Hall

What will be the value of primary key generated when the new customer is added?
o 1001
o 1000
o 2000
o1

Ans – 2000

All necessary imports are done
o restTemplate.deleteForObject(url, studentDTO.class, studentId);

o restTemplate.delete(url, studentDTO.class, studentId);
o restTemplate.delete(url, studentId);
o restTemplate.deleteForObject(url, studentId);

Ans – o restTemplate.delete(url, studentId);

What methods will match the following pointcut expression?
o None:SpringAOP supports only advising public methods.
o All Private methods of com.infy.Allocation class whose name is “find”,
takes any number of arguments and returns void
o Any Private methods of com.infy.Allocation class whose name is “find”,
takes any number of arguments
o Private methods of com.infy.Allocation class whose name is “find”, takes
any number of arguments

Ans – None:SpringAOP supports only advising public methods.

Choose an option
o Welcome to Spring Book
Hello World
I am a Spring Boot Application
o Welcome to Demo Application
Hello World
I am a Spring Boot Application
o I am a Spring Boot Application
Welcome to Demo Application
Hello World – OR 1st option(not Sure)
o Exception generated at the Line 1 due to an ambiguity in the key
“Welcome”

Ans – o Welcome to Spring Book
Hello World
I am a Spring Boot Application

Choose an option.
o Add following annotations to path variable employeeId;
@Min(value=1000)
@Max(value9999)
o Add following annotations to path variable employeeId;
@Valid
@Min(value=1000)
@Max(value9999)
o Add following annotations to path variable employeeId;
@Min(value=1000)
@Max(value9999)
Add @Validated annotation at class level
o Add following annotations to path variable employeeId;
@Min(value=1000)
Add @Validated annotation at class level.

Ans – Add following annotations to path variable employeeId;
@Valid
@Min(value=1000)
@Max(value9999)

Choose TWO correct options.
o @OneToMany(cascade = CascadeType.ALL)
@JoinColumn(name = “stream_id”)
o @ManyToOne(cascade = CascadeType.ALL)
@JoinColumn(name = “stream_id”)
o @OneToMany(cascade = CascadeType.ALL)
@JoinColumn(name = “streamid”)
o @OneToMany(cascade = CascadeType.ALL)
@JoinColumn(name = “stream_id”, unique = true)

Ans – o @OneToMany(cascade = CascadeType.ALL)
@JoinColumn(name = “stream_id”)

o @OneToMany(cascade = CascadeType.ALL)
@JoinColumn(name = “stream_id”, unique = true)

What is output?
o Name = Monica
City = null
o Name = Monica
City = Washington
o NoSuchBeanDefinitionException will be thrown
o Name = Monica will be displayed and NullPointerException will be thrown

Ans – o Name = Monica
City = null

What will be the value of productId generated, when a new row is inserted.
o 2003
o1
o 0001
o 2000

Ans – 2003

Assumption: All necessary configuration and imports are done.
o Earth Mars Jupiter Saturn
o Earth Mars Saturn

Ans – o Earth Mars Saturn

Assumption: All necessary configuration and imports are done
o [36, 36, 18, 78, 480]
o [18, 36, 36, 78, 240]
o [18, 36, 18, 78, 240]
o [18, 36, 18, 78, 480]

Ans – o [18, 36, 18, 78, 480]

Choose appropriate option that satisfies the above requirements
Ans – Arrays.asList(objects).stream().map(obj -> obj.toLowercase()).filter(obj ->
obj.charAt(0)==”i”).sorted((obj1, obj2) -> obj1.length()-
obj2.length()).forEach(obj -> System.out.println(obj));

Assume all imports are done.

List<Trainee> findByDateOfGreterThanAndLessThan(LocalDate 
greaterThanDate, LocalDate lessThanDate)

Output?
o Service.INCORRECT_BONUS
o Your Performance was satisfactory
Your Performance was satisfactory
o Your Performance was satisfactory
o Your Performance was excellent
Your Performance was satisfactory

Ans – o Your Performance was excellent
Your Performance was satisfactory

Which of the following code snippet can be used to hit the getUsers()
method…

o String url = http://localhost:8765/users/users;
ListuserDTOs=restTemplate.getForObject(url,List.
class);
o String url = http://localhost:8765/users/users;
ListuserDTOs=restTemplate.getForObject(url,List.class);
o String url = http://localhost:8765/users;
ListuserDTOs=restTemplate.getForObject(url,List.class);
o String url = http://localhost:8765/users/users;
UserDTO userDTOs = restTemplate.getForObject(url, UserDTO.class);

Ans – String url = http://localhost:8765/users/users;
UserDTO userDTOs = restTemplate.getForObject(url, UserDTO.class);

What will be the output?
o invalidAmount() test case: Passes, validAmount() test case: Fails
o invalidAmount() test case: Passes, validAmount() test case: Passes
o invalidAmount() test case: Fails, validAmount() test case: Fails
o invalidAmount() test case: Fails, validAmount() test case: Passes

Ans – o invalidAmount() test case: Fails, validAmount() test case: Passes

All necessary configurations and imports are done
o @AfterThrowing(pointcut = “execution(* .com.infy.service.Impl.(..))”)
o @AfterThrowing(pointcut = “execution(* .com.infy.service.Impl.(..))”, throwing = “exception”) o @AfterThrowing(pointcut = “execution( .com.infy.service.Impl.(..))”,
throwing = “a”)
o @AfterThrowing(pointcut = “execution(* .com.infy.serv.Impl.(..))”,
throwing = “exception”)

Ans – o @AfterThrowing(pointcut = “execution(* .com.infy.serv.Impl.(..))”,
throwing = “exception”)


Leave a Reply

Your email address will not be published. Required fields are marked *