Core Java Interview Questions – Set 03

Name two subclasses of the Text Component class.

TextField and TextArea.

Where can static modifiers be used

They can be applied to variables, methods and even a block of code, static

methods and variables are not associated with any instance of class

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 accomodate platform-specific differences among windowing systems.

What Checkbox method allows you to tell if a Checkbox is checked

getState().getState()

What is numeric promotion

Numeric promotion is the conversion of a smaller numeric type to a larger numeric type, so that integer and floating-point operations may take place. In numerical promotion, byte, char, and short values are converted to int values. The int values are also converted to long values, if necessary. The long and float values are converted to double values, as required.

How does Java handle integer overflows and underflows?

It uses those low order bytes of the result that can fit into the size of the type allowed by the operation.

What is the relationship between the Canvas class and the Graphics class

A Canvas object provides access to a Graphics object via its paint() method

Does a class inherit the constructors of its superclass

A class does not inherit constructors from any of its superclasses.

What is the difference between yielding and sleeping?

When a task invokes its yield() method, it returns to the ready state. When a task invokes its sleep()method, it returns to the waiting state.

Can shift operators be applied to float types

No, shift operators can be applied only to integer or long types