Wednesday, March 28, 2007

Java Interview Questions- Part 6

What advantage do Java's layout managers provide over traditional windowing systems?
Java uses layout managers to lay out components in a consistent manner across all windowing platforms. Since Java's layout managers aren't tied to absolute sizing and positioning, they are able to accommodate platform-specific differences among windowing systems.
--------------------------------------------------------------------------------
What are the problems faced by Java programmers who don't use layout managers?
Without layout managers, Java programmers are faced with determining how their GUI will be displayed across multiple windowing systems and finding a common sizing and positioning that will work within the constraints imposed by each windowing system.
--------------------------------------------------------------------------------
What is the difference between static and non-static variables?
A static variable is associated with the class as a whole rather than with specific instances of a class. Non-static variables take on unique values with each object instance.
--------------------------------------------------------------------------------
What is the difference between the paint() and repaint() methods?
The paint() method supports painting via a Graphics object. The repaint() method is used to cause paint() to be invoked by the AWT painting thread.
--------------------------------------------------------------------------------
What is the purpose of the File class?
The File class is used to create objects that provide access to the files and directories of a local file system.
--------------------------------------------------------------------------------
How does multithreading take place on a computer with a single CPU?
The operating system's task scheduler allocates execution time to multiple tasks. By quickly switching between executing tasks, it creates the impression that tasks execute sequentially.
--------------------------------------------------------------------------------
What restrictions are placed on method overloading?
Two methods may not have the same name and argument list but different return types.
--------------------------------------------------------------------------------
What restrictions are placed on method overriding?
Overridden methods must have the same name, argument list, and return type. The overriding method may not limit the access of the method it overrides. The overriding method may not throw any exceptions that may not be thrown by the overridden method.
--------------------------------------------------------------------------------
What is casting?
There are two types of casting, casting between primitive numeric types and casting between object references. Casting between numeric types is used to convert larger values, such as double values, to smaller values, such as byte values. Casting between object references is used to refer to an object by a compatible class, interface, or array type reference.
--------------------------------------------------------------------------------
Name Container classes. Window, Frame, Dialog, FileDialog, Panel, Applet, or ScrollPane
--------------------------------------------------------------------------------
What class allows you to read objects directly from a stream?
The ObjectInputStream class supports the reading of objects from input streams.
--------------------------------------------------------------------------------
How are this() and super() used with constructors? this() is used to invoke a constructor of the same class.
super() is used to invoke a superclass constructor.
--------------------------------------------------------------------------------
How is it possible for two String objects with identical values not to be equal under the == operator?
The == operator compares two objects to determine if they are the same object in memory. It is possible for two String objects to have the same value, but located indifferent areas of memory. --------------------------------------------------------------------------------
What an I/O filter?
An I/O filter is an object that reads from one stream and writes to another, usually altering the data in some way as it is passed from one stream to another.
--------------------------------------------------------------------------------

No comments: