Get Latest Job Updates

Get Latest Walkins and Job Updates Directly to your Inbox.
20,000 People Subscribed

Sign Up Now.
Email address
Secure and Spam free...

Java Interview Questions-5

Java Interview Questions-5

Java Interview Questions

 

today and tomorrow walkins jobs in india for freshers and experienced

 

 

1. What is the purpose of the System class?

The purpose of the System class is to provide access to system resources.

2. List primitive Java types?

The eight primitive types are byte, char, short, int, long, float, double, and boolean.

3. What is the relationship between clipping and repainting under AWT?

When a window is repainted by the AWT painting thread, it sets the clipping regions to the area of the window that requires repainting.
4. Which class is the immediate superclass of the Container class?

Component class is the immediate super class.
5. What class of exceptions are generated by the Java run-time system?

The Java runtime system generates RuntimeException and Error exceptions.
6. Under what conditions is an object’s finalize method invoked by the garbage collector?

The garbage collector invokes an object’s finalize method when it detects that the object has become unreachable.
7. How can a dead thread be restarted?

A dead thread cannot be restarted.


8. Which arithmetic operations can result in the throwing of an ArithmeticException?

Integer / and % can result in the throwing of an ArithmeticException.
9. Variable of the boolean type is automatically initialized as?

The default value of the boolean type is false.
10. Can try statements be nested?

Yes
11. What are ClassLoaders?

A class loader is an object that is responsible for loading classes. The class ClassLoader is an
abstract class.
12. What is the difference between an Interface and an Abstract class?

An abstract class can have instance methods that implement a default behavior. An Interface can only declare constants and instance methods, but cannot implement default behavior and all
methods are implicitly abstract. An interface has all public members and no implementation.
13. What will happen if static modifier is removed from the signature of the main method?

Program throws “NoSuchMethodError” error at runtime.
14. What is the default value of an object reference declared as an instance variable?

Null, unless it is defined explicitly.
15. Can a top level class be private or protected?

No, a top level class can not be private or protected. It can have either “public” or no modifier.
16. Why do we need wrapper classes?

We can pass them around as method parameters where a method expects an object. It also provides utility methods.
17. What is the difference between error and an exception?

An error is an irrecoverable condition occurring at runtime. Such as OutOfMemory error.Exceptions are conditions that occur because of bad input etc. e.g. FileNotFoundException will be
thrown if the specified file does not exist.
18. Is it necessary that each try block must be followed by a catch block?

It is not necessary that each try block must be followed by a catch block. It should be followed by either a catch block or a finally block.
19. When a thread is created and started, what is its initial state?

A thread is in the ready state as initial state after it has been created and started.


20. What is the Locale class?

The Locale class is used to tailor program output to the conventions of a particular geographic,political, or cultural region.
21. What are synchronized methods and synchronized statements?

Synchronized methods are methods that are used to control access to an object. A synchronizedstatement can only be executed after a thread has acquired the lock for the object or class
referenced in the synchronized statement.
22. What is runtime polymorphism or dynamic method dispatch?

Runtime polymorphism or dynamic method dispatch is a process in which a call to an overridden method is resolved at runtime rather than at compile-time. In this process, an overridden method
is called through the reference variable of a superclass.
23. What is Dynamic Bindinglatebinding?

Binding refers to the linking of a procedure call to the code to be executed in response to the call.Dynamic binding means that the code associated with a given procedure call is not known until the time of the call at run-time.
24. Can constructor be inherited?

No, constructor cannot be inherited.
25. What are the advantages of ArrayList over arrays?

ArrayList can grow dynamically and provides more powerful insertion and search mechanisms than arrays.