KyaPoocha.com

Huge Collection of Interview Questions


Archive for April, 2008

Short Core Java Interview Questions ? 

1. Primitive data types are passed by reference or pass by value ? Ans. Primitive data types are passed by value. 2. How to create custom exceptions ? Ans. Your... Read more »

Considering the basic properties of Vector and ArrayList, where will you use Vector and where will you use ArrayList ? 

The basic difference between a Vector and an ArrayList is that, vector is synchronized while ArrayList is not. Thus whenever there is a possibility of multiple threads... Read more »

What is an enumeration ? 

An enumeration is an interface containing methods for accessing the underlying data structure from which the enumeration is obtained. It is a construct which collection... Read more »

What is the difference between the size and capacity of a Vector ? 

The size is the number of elements actually stored in the vector, while capacity is the maximum number of elements it can store at a given instance of time.  Read more »

How does a try statement determine which catch clause should be used to handle an exception ? 

When an exception is thrown within the body of a try statement, the catch clauses of the try statement are examined in the order in which they appear. The first... Read more »

What are the steps in the JDBC connection ? 

While making a JDBC connection we go through the following steps : Step 1 : Register the database driver by using : Class.forName(\” driver classs for that... Read more »

Can applets communicate with each other ? 

At this point in time applets may communicate with other applets running in the same virtual machine. If the applets are of the same class, they can communicate... Read more »

If I write System.exit (0); at the end of the try block, will the finally block still execute ? 

No in this case the finally block will not execute because when you say System.exit (0); the control immediately goes out of the program, and thus finally never... Read more »

What is the basic difference between the 2 approaches to exception handling…1> try catch block and 2> specifying the candidate exceptions in the throws clause? When should you use which approach ? 

In the first approach as a programmer of the method, you urself are dealing with the exception. This is fine if you are in a best position to decide should be done... Read more »

What happens to an unhandled exception ? 

One can not do anytihng in this scenarion. Because Java does not allow multiple inheritance and does not provide any exception interface as well.  Read more »

If my class already extends from some other class what should I do if I want an instance of my class to be thrown as an exception object ? 

One can not do anytihng in this scenarion. Because Java does not allow multiple inheritance and does not provide any exception interface as well.  Read more »

If I want an object of my class to be thrown as an exception object, what should I do ? 

The class should extend from Exception class. Or you can extend your class from some more precise exception type also.  Read more »

Why do we need wrapper classes ? 

It is sometimes easier to deal with primitives as objects. Moreover most of the collection classes store objects and not primitive data types. And also the wrapper... Read more »

What happens to the static fields of a class during serialization? Are these fields serialized as a part of each serialized object ? 

Yes the static fields do get serialized. If the static field is an object then it must have implemented Serializable interface. The static fields are serialized... Read more »

Objects are passed by value or by reference ? 

Java only supports pass by value. With objects, the object reference itself is passed by value and so both the original reference and parameter copy both refer to... Read more »

Page 1 of 1512345»...Last »