package com.infy.config;

@Configuration

@ComponentScan

public class SpringConfig { }

package com.infy.demo;

@Component

public class Customer {

private String customerName;

//getters and setters

public String registerCustomer(String name) {

return "Welcome " + name + "! You are now our registered user!!";

}

}

package com.infy.ui;

public class UserInterface {

public static void main(String[] args) {

ApplicationContext context= new AnnotationConfigApplicationContext(SpringConfig.class);

Customer customer=(Customer) context.getBean("customer");

customer.setCustomerName("Tanaka");

System.out.println(customer.registerCustomer(customer.getCustomerName()));

}

}

What will be the output for the above code?

Welcome !You are now our registered user!!

NoSuchBean Exception

Welcome Tarika! You are now our registered user!!

Welcome null! You are now our registered user!!

Verified Answer
Correct Option - b

To get all Infosys Certified Spring Boot Developer Exam questions Join Group https://bit.ly/infy_premium_group

We're passionate about offering best placement materials and courses!! A one stop place for Placement Materials. We daily post Offcampus updates and Placement Materials.

Qtr No. 213, New Town Yehlanka Indore 454775

admin@prepflix.in