This set of Advanced Java Multiple Choice Questions & Answers (MCQs) focuses on “Java Beans”.
1. Which of the following is not an Enterprise Beans type?
a) Doubleton
b) Singleton
c) Stateful
d) Stateless
View Answer
Explanation: Stateful, Stateless and Singleton are session beans.
2. Which of the following is not true about Java beans?
a) Implements java.io.Serializable interface
b) Extends java.io.Serializable class
c) Provides no argument constructor
d) Provides setter and getter methods for its properties
View Answer
Explanation: java.io.Serializable is not a class. Instead it is an interface. Hence it cannot be extended.
3. Which file separator should be used by MANIFEST file?
a) /
b) \
c) –
d) //
View Answer
Explanation: MANIFEST file uses classes using / file separator.
4. Which of the following is correct error when loading JAR file with duplicate name?
a) java.io.NullPointerException
b) java.lang.ClassNotFound
c) java.lang.ClassFormatError
d) java.lang.DuplicateClassError
View Answer
Explanation: java.lang.ClassFormatError: Duplicate Name error is thrown when .class file in the JAR contains a class whose class name is different from the expected name.
5. Java Beans are extremely secured?
a) True
b) False
View Answer
Explanation: JavaBeans do not add any security features to the Java platform.
6. Which of the following is not a feature of Beans?
a) Introspection
b) Events
c) Persistence
d) Serialization
View Answer
Explanation: Serialization is not the feature of Java Beans. Introspection, Customization, Events, Properties and Persistence are the features.
7. What is the attribute of java bean to specify scope of bean to have single instance per Spring IOC?
a) prototype
b) singleton
c) request
d) session
View Answer
Explanation: Singleton scope of bean specifies only one instance per spring IOC container. This is the default scope.
8. Which attribute is used to specify initialization method?
a) init
b) init-method
c) initialization
d) initialization-method
View Answer
Explanation: init-method is used to specify the initialization method.
<bean id = "helloWorld" class = "com.bean.HelloWorld" init-method = "init" />
9. Which attribute is used to specify destroy method?
a) destroy
b) destroy-method
c) destruction
d) destruction-method
View Answer
Explanation: destroy-method is used to specify the destruction method.
<bean id = "helloWorld" class = "com.tutorialspoint.HelloWorld" destroy-method = "destroy" />
10. How to specify autowiring by name?
a) @Qualifier
b) @Type
c) @Constructor
d) @Name
View Answer
Explanation: Different beans of the same class are identified by name.
@Qualifier("student1")
@Autowired
Student student1;
No comments:
Post a Comment