Thursday, June 24, 2010

CORE JAVA CONTINUES ... 6

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

QUESTION: What is the difference between a field variable and a local variable?
ANSWER: A field variable is a variable that is declared as a member of a class. A local variable is a variable that is declared local to a method.

QUESTION: How are this() and super() used with constructors?
ANSWER: this() is used to invoke a constructor of the same class. super() is used to invoke a superclass constructor.

QUESTION: What is the relationship between a method's throws clause and the exceptions that can be thrown during the method's execution?
ANSWER: A method's throws clause must declare any checked exceptions that are not caught within the body of the method.

QUESTION: Why are the methods of the Math class static?
ANSWER: So they can be invoked as if they are a mathematical code library.

QUESTION: What are the legal operands of the instanceof operator?
ANSWER: The left operand is an object reference or null value and the right operand is a class, interface, or array type.

QUESTION: What an I/O filter?
ANSWER: An I/O filter is an object that reads from one stream and writes to another, usually altering the data in some way as it is passed from one stream to another.

QUESTION: If an object is garbage collected, can it become reachable again?
ANSWER: Once an object is garbage collected, it ceases to exist. It can no longer become reachable again.

QUESTION: What are E and PI?
ANSWER: E is the base of the natural logarithm and PI is mathematical value pi.

QUESTION: Are true and false keywords?
ANSWER: The values true and false are not keywords.
QUESTION: What is the difference between the File and RandomAccessFile classes?
ANSWER: The File class encapsulates the files and directories of the local file system. The RandomAccessFile class provides the methods needed to directly access data contained in any part
of a file.

QUESTION: What happens when you add a double value to a String?
ANSWER: The result is a String object.

QUESTION: What is your platform's default character encoding?
ANSWER: If you are running Java on English Windows platforms, it is probably Cp1252. If you are running Java on English Solaris platforms, it is most likely 8859_1.

QUESTION: Which package is always imported by default?
ANSWER: The java.lang package is always imported by default.

QUESTION: What interface must an object implement before it can be written to a stream as an object?
ANSWER: An object must implement the Serializable or Externalizable interface before it can be written to a stream as an object.