Interview Questions
Java |
What is the immediate superclass of Menu? |
Ans: MenuItem. |
In which package are most of the AWT events that support the event-delegation model defined? |
Ans: Most of the AWT-related events of the event-delegation model are defined in the java.awt.event package. The AWTEvent class is defined in the java.awt package. |
What is the range of the char type? |
Ans: The range of the char type is 0 to 2^16 - 1. |
What is the range of the short type? |
Ans: The range of the short type is -(2^15) to 2^15 - 1. |
Can an anonymous class be declared as implementing an interface and extending a class? |
Ans: An anonymous class may implement an interface or extend a superclass, but may not be declared to do both. |
When a thread is created and started, what is its initial state? |
Ans: A thread is in the ready state after it has been created and started. |
What class is the top of the AWT event hierarchy? |
Ans: The java.awt.AWTEvent class is the highest-level class in the AWT event-class hierarchy. |
What is a task's priority and how is it used in scheduling? |
Ans: A task's priority is an integer value that identifies the relative order in which it should be executed with respect to other tasks. The scheduler attempts to schedule higher priority tasks before lower priority tasks. |
What is the difference between a MenuItem and a CheckboxMenuItem? |
Ans: The CheckboxMenuItem class extends the MenuItem class to support a menu item that may be checked or unchecked. |
What is the catch or declare rule for method declarations? |
Ans: If a checked exception may be thrown within the body of a method, the method must either catch the exception or declare it in its throws clause. |