Wednesday, October 24, 2007

CORE JAVA Interview Questions-Part15


Question: What is the difference between a while statement and a do statement?

Answer: A while statement checks at the beginning of a loop to see whether the next loop iteration should occur. A do statement checks at the end of a loop to see whether the next iteration of a loop should occur. The do statement will always execute the body of a loop at least once.

Question: What modifiers can be used with a local inner class?

Answer: A local inner class may be final or abstract.

Question: What is the purpose of the File class?

Answer: The File class is used to create objects that provide access to the files and directories of a local file system.

Question: Can an exception be rethrown?

Answer: Yes, an exception can be rethrown.

Question: When does the compiler supply a default constructor for a class?

Answer: The compiler supplies a default constructor for a class if no other constructors are provided.

Question: If a method is declared as protected, where may the method be accessed?

Answer: 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.

Question: Which non-Unicode letter characters may be used as the first character of an identifier?

Answer: The non-Unicode letter characters $ and _ may appear as the first character of an identifier

Question: What restrictions are placed on method overloading?

Answer: Two methods may not have the same name and argument list but different return types.

Question: What is casting?

Answer: 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.

Question: What is the return type of a program's main() method?

Answer: A program's main() method has a void return type

0 comments:

Advertisement

 

Copyright 2008 All Rights Reserved Revolution Two Church theme by Brian Gardner Converted into Blogger Template by Bloganol dot com