Advanced Java - Interview Questions XIII


Q. What is the Set interface?
The Set interface provides methods for accessing the elements of a finite mathematical set. Sets do not allow duplicate elements.

Q. What classes of exceptions may be thrown by a throw statement?
A throw statement may throw any expression that may be assigned to the Throwable type.

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

Q. Are true and false keywords?
The values true and false are not keywords.

Q. What is a void return type?
A void return type indicates that a method does not return a value.

Q. What is the purpose of the enableEvents() method?
The enableEvents() method is used to enable an event for a particular object. Normally, an event is enabled when a listener is added to an object for a particular event.
The enableEvents() method is used by objects that handle events by overriding their event-dispatch methods.

Q. What is the difference between the File and RandomAccessFile classes?
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.

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

Q. What is your platform's default character encoding?
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.

Q. Which package is always imported by default?
The java.lang package is always imported by default.

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

Q. How are this and super used?
this is used to refer to the current object instance.
super is used to refer to the variables and methods of the superclass of the current object instance.

Comments