Java Review Questions - For Revisions

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.

Can an exception be rethrown? 
Yes, an exception can be rethrown. 

Which Math method is used to calculate the absolute value of a number? 
The abs() method is used to calculate absolute values. 

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.

When does the compiler supply a default constructor for a class?
The compiler supplies a default constructor for a class if no other constructors are provided.

When is the finally clause of a try-catch-finally statement executed?
The finally clause of the try-catch-finally statement is always executed unless the thread of execution terminates or an exception occurs within the execution of the finally clause.

Which class is the immediate superclass of the Container class? 
Component 

If a method is declared as protected, where may the method be accessed? 
A protected method may only be accessed by classes or interfaces of the same package or by subclasses of the class in which it is declared.

How can the Checkbox class be used to create a radio button? 
By associating Checkbox objects with a CheckboxGroup. 

Which non-Unicode letter characters may be used as the first character  of an identifier? 
The non-Unicode letter characters $ and _ may appear as the first character of an identifier 

What restrictions are placed on method overloading? 
Two methods may not have the same name and argument list but different return types.

What happens when you invoke a thread's interrupt method while it is  sleeping or waiting? 
When a task's interrupt() method is executed, the task enters the ready state. The next time the task enters the running state, an InterruptedException is thrown. 

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.

What is the return type of a program's main() method? 
A program's main() method has a void return type. 

Name four Container classes. 
Window, Frame, Dialog, FileDialog, Panel, Applet, or ScrollPane

What is the difference between a Choice and a List?
A Choice is displayed in a compact form that requires you to pull it down to see the list of available choices. Only one item may be selected from a Choice. A List may be displayed in such a way that several List items are visible. A List supports the selection of one or more List items.

What class of exceptions are generated by the Java run-time system?
The Java runtime system generates RuntimeException and Error exceptions.

What class allows you to read objects directly from a stream?
The ObjectInputStream class supports the reading of objects from input streams.

More Java Questions

Do you have a Java Problem?
Ask It in The Java Forum

Java Books
Java Certification, Programming, JavaBean and Object Oriented Reference Books

Return to : Java Programming Hints and Tips

All the site contents are Copyright © www.erpgreat.com and the content authors. All rights reserved.
All product names are trademarks of their respective companies.
The site www.erpgreat.com is not affiliated with or endorsed by any company listed at this site.
Every effort is made to ensure the content integrity.  Information used on this site is at your own risk.
 The content on this site may not be reproduced or redistributed without the express written permission of
www.erpgreat.com or the content authors.