-
How are the elements of a GridBagLayout organized
The elements of a GridBagLayout are organized according to a grid. However, theelements are of differentsizes and may occupy more than one row or column of the grid. In addition, the rows andcolumns mayhave different sizes.
-
What advantage do Java's layout managers provide over traditional windowingsystems
Java uses layout managers to lay out components in a consistent manner across allwindowing platforms.Since Java's layout managers aren't tied to absolute sizing and positioning, they are ableto accomodateplatform-specific differences among windowing systems.
-
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 instancesof a class. Nonstaticvariables take on unique values with each object instance.
-
How does multithreading take place on a computer with a single CPU
The operating system's task scheduler allocates execution time to multiple tasks. Byquickly switchingbetween executing tasks, it creates the impression that tasks execute sequentially.
-
What happens when you invoke a thread's interrupt method while it issleeping or waiting
When a task's interrupt() method is executed, the task enters the ready state. The nexttime the task entersthe running state, an InterruptedException is thrown.
-
What is casting
There are two types of casting, casting between primitive numeric types and castingbetween objectreferences. Casting between numeric types is used to convert larger values, such asdouble values, tosmaller values, such as byte values. Casting between object references is used to refer toan object by acompatible class, interface, or array type reference.
-
What is the difference between the JDK 1.02 event model and the eventdelegationmodelintroduced with JDK 1.1
The JDK 1.02 event model uses an event inheritance or bubbling approach. In this model,components arerequired to handle their own events. If they do not handle a particular event, the event isinherited by (orbubbled up to) the component's container. The container then either handles the event orit is bubbled up toits container and so on, until the highest-level container has been tried.In the event-delegation...
-
How is it possible for two String objects with identical values not to be equalunder the ==operator
The == operator compares two objects to determine if they are the same object inmemory. It is possible fortwo String objects to have the same value, but located indifferent areas of memory.
-
What is the purpose of the enableEvents() method
The enableEvents() method is used to enable an event for a particular object. Normally,an event is enabledwhen a listener is added to an object for a particular event. The enableEvents() method isused by objectsthat handle events by overriding their event-dispatch methods.
-
What is the difference between the File and RandomAccessFile classes
The File class encapsulates the files and directories of the local file system. TheRandomAccessFile classprovides the methods needed to directly access data contained in any part of a file.
-
What is your platform's default character encoding
If you are running Java on English Windows platforms, it is probably Cp1252. If you arerunning Java onEnglish Solaris platforms, it is most likely 8859_1..
-
What restrictions are placed on method overriding
Overridden methods must have the same name, argument list, and return type. Theoverriding method maynot limit the access of the method it overrides. The overriding method may not throwany exceptions thatmay not be thrown by the overridden method.
-
What happens if a try-catch-finally statement does not have a catch clause tohandle anexception that is thrown within the body of the try statement
The exception propagates up to the next higher level try-catch statement (if any) orresults in the program'stermination.
-
What is numeric promotion
Numeric promotion is the conversion of a smaller numeric type to a larger numeric type,so that integer andfloating-point operations may take place. In numerical promotion, byte, char, and shortvalues areconverted to int values. The int values are also converted to long values, if necessary.The long and floatvalues are converted to double values, as required.
-
What is the difference between the prefix and postfix forms of the ++ operator
The prefix form performs the increment operation and returns the value of the incrementoperation. Thepostfix form returns the current value all of the expression and then performs theincrement operation onthat value.
-
What is a Java package and how is it used
A Java package is a naming context for classes and interfaces. A package is used tocreate a separate namespace for groups of classes and interfaces. Packages are also used to organize relatedclasses and interfacesinto a single API unit and to control accessibility to these classes and interfaces.
-
How does a try statement determine which catch clause should be used tohandle an exception
When an exception is thrown within the body of a try statement, the catch clauses of thetry statement areexamined in the order in which they appear. The first catch clause that is capable ofhandling the exceptionis executed. The remaining catch clauses are ignored.
-
What are synchronized methods and synchronized statements
Synchronized methods are methods that are used to control access to an object. A threadonly executes asynchronized method after it has acquired the lock for the method's object or class.Synchronizedstatements are similar to synchronized methods. A synchronized statement can only beexecuted after athread has acquired the lock for the object or class referenced in the synchronizedstatement.
-
What are the two basic ways in which classes that can be run as threads may bedefined
A thread class may be declared as a subclass of Thread, or it may implement theRunnable interface.
-
What are the problems faced by Java programmers who don't use layoutmanagers
Without layout managers, Java programmers are faced with determining how their GUIwill be displayedacross multiple windowing systems and finding a common sizing and positioning thatwill work within theconstraints imposed by each windowing system.
Java Interview Questions
Ans