Thursday, 16 June 2011

Technical Interview "Java" Questions

If a variable is declared as private, where may the variable be accessed?
http://materialsforjob.blogspot.com
It may be accessed in any of the methods defined in that class. Generally for the security of the variables we declare them as private and using the public methods in the class we use them. Making sure that variables are accessible only in that class.
What is the difference between Abstract class and Interface?
An abstract class can contain non-abstract methods which do not have to be overridden in the subclass.
There is no difference between a fully abstract class (all methods declared as abstract and all fields are public static final) and an interface.
How to create a Tabbed Pane in JSP page?
//declare
private JTabbedPane pane ;
//initialise
pane = new JTabbedPane();
//add GUI components to the TABPANE
pane.addTab(nameoftab, component);

Why getInstance() method is used along with class declaration in Java?
This method is used to tracing the instance in your application. Which instance is running of the class.

What is the immediate superclass of the Dialog class?
System.Windows.Forms.CommonDialog
What is the difference between string and string buffer?
String objects are constants & immutable string Buffer objects are not constants & growable
What is the return type of a program's main() method?
A program's main() method has a void return type.

What is the default size of Vector, Arraylist, Hashtable, Hashmap, Hashset in Java?
A vector has its default capacity which is 10 elements, here size is different from capacity, after 10 element if we enter one element the capacity of vector changes to 20 were as size is 11 only, for example if you have entered 21 elements in a vector, then if you print v.size it results 21 but v.capacity it results 30 If you have any further queries please let me know

What is the difference between a Window and a Frame?
The Frame class extends Window to define a main application window that can have a menu bar.
What is the difference between static variable and instance variable?
Static variable the field is allocated when the class is created. It belongs to the class and not any object of the class. It is class variable

Instance variable the field is allocated when the class is instantiated to the class is called instance variable or non-static variable
What modifiers may be used with a top-level class?
The modifiers a top-level class can have are public and either abstract or final.
A nested class is any class whose declaration occurs within the body of another class or interface. A top level class is a class that is not a nested class. In other words, a top level class is any class that is not declared within another class or interface.
The modifiers private and protected can only be used with member classes, a top level class is not a member class, it can never be a member class, because if it were a member class it would by definition be a nested class and by definition would not be a top level class.

0 comments:

Post a Comment

Search here for "Freshers Jobs"