Wednesday, February 5, 2014

For Java resources - 0 to 2 years

Java Static

Q. When are static variables loaded in memory ?
Correct Answer. Runtime, when the class is loaded.

Q. Difference between static and instance methods in memory ?
Correct Answer. Instance methods have context as refernce to the instance whereas static methods don't have.

Q. Does Java allow overriding static methods?
Correct Answer. No

Q. Can we serialize static members? 
Correct Answer. No.

Q. Can interface have static member variables?
Correct Answer. Yes.

Q. Can we declare an interface method static?
Correct Answer. No.

Q. Are Nested Interfaces static by default ?
Correct Answer. Yes.

Q. Can we have runtime polymorphism using static methods ?
Correct Answer. No.

Q. Which of the following is true ?
Correct Answer. Class cannot be declared static but nested class can be.

Q. Which of the following is true about static block ?
Correct Answer. It get's executed when the class is loaded.

Java abstract Classes and Interfaces

Q. Can we declare an interface method private ?
Correct Answer. No.

Q. Can interface have static members ?
Correct Answer. Static variables only.

Q. Can we declare a class abstract and final ?
Correct Answer. No.

Q. Can an interface extend another interface ?
Correct Answer. Yes

Q. Can a class implement multiple interfaces ?
Correct Answer. Yes

Q. Which of the following are marker interfaces ?
Correct Answer. Serializable.

Q. Interface method declarations are implicitly .. 
Correct Answer. public

Q. Do interfaces have constructors ?
Correct Answer. No.

Q. Can an interface be final ?
Correct Answer. No.

Q. We can nest interface within ..
Correct Answer. Both of them.

Struts  1+ Framework

Q.Struts is a
Correct Answer.Framework

Q.MVC is
Correct Answer.Design Pattern

Q.Which configuration files are used in struts for Validation Framework ?
Correct Answer.Validator-rules.xml and Validation.xml

Q.Which of following is true about Struts 1 and Struts 2
Correct Answer.Both a and b

Q.How many struts config file we can have ?
Correct Answer.Multiple

Q.Where do we specify servlet Mapping ?
Correct Answer.web.xml

Q.Where do we specify action Mapping ?
Correct Answer.struts-config,xml

Q.validate and Reset methods are defined in
Correct Answer.Form Beans

Q.What is controller in Struts ?
Correct Answer.Servlet

Q.How many instances of servlet usually run in a struts application
Correct Answer.1

#############################################################

Q. Which of the following is not true for abstract classes ?
Correct Answer. We can't have an abstract class without abstract methods.

Q. Which of the following is not true for static keyword ?
Correct Answer. We can override static methods.

Q. Which of the following is an Immutable Class ?
Correct Answer. String

Q. What is the difference between .equal and == ?
Correct Answer. == matches to see if they are same object whereas .equal matches the content of the objects.


Q. Which of the following is not the method of object class ?
Correct Answer. system

Q. Which of the following is True about final keyword ?
Correct Answer. We can't declare a class abstract as well as final.

Q. Which of the following is false about collections in Java ?
Correct Answer. list , Map and Set are abstract classes

Q. Which of the following is incorrect ?
Correct Answer. JVM is Java Visual Machine.

Q. Following are the class loaders used by JVM ?
Correct Answer. Bootstrap , Extension and Virtual

Q. Which of the following is not true for hashtable and hasmaps ?
Correct Answer. HashMaps are synchronized whereas hashtables are not.

No comments: