Friday, March 4, 2016

MCQ Advanced Java Questions & Answers – Java Beans


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

Answer: a
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

Answer: b
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

Answer: a
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

Answer: c
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

Answer: b
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

Answer: d
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

Answer: b
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

Answer: b
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

Answer: b
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

Answer: a
Explanation: Different beans of the same class are identified by name.

  1. 	     @Qualifier("student1")
  2. 	     @Autowired
  3. 	     Student student1;


No comments:

Post a Comment

CORBA Java Tutorial using Netbeans and Java 8.

CORBA-Example A simple CORBA implementation using Java Echo.idl module EchoApp{ interface Echo{ string echoString(); }; }; ...