KyaPoocha.com

Huge Collection of Interview Questions


Archive for August, 2006

What are some alternatives to inheritance? 

Delegation is an alternative to inheritance. Delegation means that you include an instance of another class as an instance variable, and forward messages to the... Read more »

If I write return at the end of the try block, will the finally block still execute? 

Yes even if you write return as the last statement in the try block and no exception occurs, the finally block will execute. The finally block will execute and then... Read more »

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. And whatever exceptions... Read more »

What are the different ways to handle exceptions? 

There are two ways to handle exceptions, 1. By wrapping the desired code in a try block followed by a catch block to catch the exceptions. and 2. List the desired... Read more »

How does an exception permeate through the code? 

An unhandled exception moves up the method stack in search of a matching When an exception is thrown from a code which is wrapped in a try block followed by one... Read more »

What is the difference between error and an exception? 

An error is an irrecoverable condition occurring at runtime. Such as OutOfMemory error. These JVM errors and you can not repair them at runtime. While exceptions... Read more »

What are runtime exceptions? 

Runtime exceptions are those exceptions that are thrown at runtime because of either wrong input data or because of wrong business logic etc. These are not checked... Read more »

What are checked exceptions? 

Checked exception are those which the Java compiler forces you to catch. e.g. IOException are checked Exceptions.  Read more »

Does Java provide any construct to find out the size of an object? 

No there is not sizeof operator in Java. So there is not direct way to determine the size of an object directly in Java.  Read more »

What is Externalizable interface? 

Externalizable is an interface which contains two methods readExternal and writeExternal. These methods give you a control over the serialization mechanism. Thus... Read more »

What type of parameter passing does Java support? 

In Java the arguments are always passed by value .  Read more »

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. If it does not have a modifier it is supposed to have... Read more »

What is the difference between declaring a variable and defining a variable? 

In declaration we just mention the type of the variable and it’s name. We do not initialize it. But defining means declaration + initialization. e.g String... Read more »

What are different types of inner classes? 

Nested top-level classes, Member classes, Local classes, Anonymous classes Nested top-level classes- If you declare a class within a class and specify the static... Read more »

What is Overriding? 

When a class defines a method using the same name, return type, and arguments as a method in its superclass, the method in the class overrides the method in the... Read more »

Page 1 of 1612345»...Last »