Wednesday, September 26, 2007

Java Interview Questions-6

Question: How can you write a loop indefinitely?
Answer:
for(;;)--for loop; while(true)--always true, etc.

Question:. Can an anonymous class be declared as implementing an interface and extending a class?
Answer:
An anonymous class may implement an interface or extend a superclass, but may not be declared to do both.

Question: What is the purpose of finalization?
Answer:
The purpose of finalization is to give an unreachable object the opportunity to perform any cleanup processing before the object is garbage collected.

Question: Which class is the superclass for every class.
Answer:
Object.

Question: What is the difference between the Boolean & operator and the && operator?
Answer:
If an expression involving the Boolean & operator is evaluated, both operands are evaluated. Then the & operator is applied to the operand. When an expression involving the && operator is evaluated, the first operand is evaluated. If the first operand returns a value of true then the second operand is evaluated. The && operator is then applied to the first and second operands. If the first operand evaluates to false, the evaluation of the second operand is skipped.
Operator & has no chance to skip both sides evaluation and && operator does. If asked why, give details as above.

Question: What is the GregorianCalendar class?
Answer:
The GregorianCalendar provides support for traditional Western calendars.

Question: What is the SimpleTimeZone class?
Answer:
The SimpleTimeZone class provides support for a Gregorian calendar.

Question: Which Container method is used to cause a container to be laid out and redisplayed?
Answer:
validate()

Question: What is the Properties class?
Answer:
The properties class is a subclass of Hashtable that can be read from or written to a stream. It also provides the capability to specify a set of default values to be used.

Question: What is the purpose of the Runtime class?
Answer:
The purpose of the Runtime class is to provide access to the Java runtime system.

Question: What is the purpose of the System class?
Answer:
The purpose of the System class is to provide access to system resources.

No comments:

My Ad

.