Preliminary Java Questions
Preliminary Java Questions
How many methods do you implement if a class implements the Serializable interface? Ans. 0 Explanation: The Serializable interface is just a "marker" interface, with no methods of its own to implement. 3. If two String objects are equal according to the equals method, does calling the hashCode method on each of the String objects will produce the same result ? A. True B. False Ans. A If above question answered correctly then What is the return type of hashCode() method ? Ans. Int 4. Can Static Methods be overridden ? A. True B. False Ans. B 5. Can Abstract Class be Instantiated? A. True B. False Ans. B 6. Can Abstract class be Final? A. True B. False Ans. B 7. Which class plays the role of controller in Struts 1.x ? Ans. ActionServlet Explanation: The class org.apache.struts.action.ActionServlet in the Struts Framework plays the role of controller. All the requests to the server go through the controller. Controller is responsible for handling all the requests. 8. What is value stack? It is a temporary storage area where framework keeps the data for particular request 9. How to configure your own interceptor in struts 2.0? Create the interceptor and write the reference in the interceptor stack in struts xml 10. What is Singleton class? Ans. Singleton class is a class in which at a time only one object can create. 11. What are the Lifecycle Methods of Servlet?
Ans: init, service, destroy 12. If a hash map has a key with a given value and user adds the same key but with different value, what will be the output if one tries to fetch value using that key? A. Not Allowed B. Latest Inserted value C. Previous value D. Compilation Fails Ans. B