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.
advertisement
advertisement

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.
Note: Join free Sanfoundry classes at Telegram or Youtube

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.
advertisement

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.

advertisement
 <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;

Sanfoundry Global Education & Learning Series – Java Programming Language.

To practice all areas of Java language, here is complete set of 1000+ Multiple Choice Questions and Answers.

If you find a mistake in question / option / answer, kindly take a screenshot and email to [email protected]

advertisement
advertisement
Subscribe to our Newsletters (Subject-wise). Participate in the Sanfoundry Certification contest to get free Certificate of Merit. Join our social networks below and stay updated with latest contests, videos, internships and jobs!

Youtube | Telegram | LinkedIn | Instagram | Facebook | Twitter | Pinterest
Manish Bhojasia - Founder & CTO at Sanfoundry
Manish Bhojasia, a technology veteran with 20+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He lives in Bangalore, and focuses on development of Linux Kernel, SAN Technologies, Advanced C, Data Structures & Alogrithms. Stay connected with him at LinkedIn.

Subscribe to his free Masterclasses at Youtube & discussions at Telegram SanfoundryClasses.