View Single Post
Old 14-01-2010, 09:22 PM   #1
javaguru
Member
 
javaguru's Avatar
 
Join Date: Dec 2009
Posts: 50
Rep Power: 15
javaguru is on a distinguished road
Cool Some latest Java Interview Questions

1. Is “abc” a primitive value? - The String literal “abc” is not a primitive value. It is a String object.

2. What restrictions are placed on the values of each case of a switch statement? -
During compilation, the values of each case of a switch statement must evaluate to a value that can be promoted to an int value.

3. What modifiers may be used with an interface declaration? - An interface may be declared as public or abstract.

4. Is a class a subclass of itself? - A class is a subclass of itself.

5. What is the difference between a while statement and a do statement? - 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.

6. What modifiers can be used with a local inner class? - A local inner class may be final or abstract.

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

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

9. 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.

10. 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.

11. 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

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

13. 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.

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

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

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

17. What is the difference between a field variable and a local variable? - 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.

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

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

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

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

22. What an I/O filter? - 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.

23. If an object is garbage collected, can it become reachable again? - Once an object is garbage collected, it ceases to exist. It can no longer become reachable again.
javaguru is offline   Reply With Quote