【C015382】Spring配置文件中有如下一段代码:
<bean id ="prototype" class="demo.MyBean" scope="prototype" />
<bean id ="default" class="demo.MyBean" />
则如下代码:
public static void main(String args[]){
ApplicationContext ac =
new ClassPathXmlApplicationContext("applicationContext.xml");
MyBean myBean1 = (MyBean) ac.getBean("prototype");
MyBean myBean2 = (MyBean) ac.getBean("prototype");
MyBean myBean3 = (MyBean) ac.getBean("default");
MyBean myBean4 = (MyBean) ac.getBean("default");
System.out.println(myBean1 == myBean2);
System.out.println(myBean3 == myBean4);
}
输出结果是( )
A.false
false
B.false
true
C.true
true
D.true
false