|
1. What is the % operator? It is referred to as the modulo or remainder operator. It returns the remainder of dividing the first operand by the second operand. 2. What is the purpose of the wait(), notify(), and notifyAll() methods? The wait(),notify(), and notifyAll() methods are used to provide an efficient way for threads to wait for a shared resource. When a thread executes an object's wait() method, it enters the waiting state. It only enters the ready state after another thread invokes the object's notify() or notifyAll() methods.. 3. Can a Byte object be cast to a double value? No, an object cannot be cast to a primitive value. 4. What must a class do to implement an interface? It must provide all of the methods in the interface and identify the interface in its implements clause. 5. Is the ternary operator written x : y ? z or x ? y : z ? It is written x ? y : z. 6. How is rounding performed under integer division? The fractional part of the result is truncated. This is known as rounding toward zero. 7. How many times may an object's finalize() method be invoked by the garbage collector? An object's finalize() method may only be invoked once by the garbage collector. 8. How are Java source code files named? A Java source code file takes the name of a public class or interface that is defined within the file. A source code file may contain at most one public class or interface. If a public class or interface is defined within a source code file, then the source code file must take the name of the public class or interface. If no public class or interface is defined within a source code file, then the file must take on a name that is different than its classes and interfaces. Source code files use the .java extension. 9. 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. 10. Which containers may have a MenuBar? Frame
|