Wednesday, September 24, 2008

Java Interview Questions and Answers - JAVA Quiz

1)What restrictions are placed on method overriding?


Overridden methods must have the same name, argument list, and return type. The overriding method may not limit the access of the method it overrides. The overriding method may not throw any exceptions that may not be thrown by the overridden method.

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

3)Explain the usage of the keyword transient?
This keyword indicates that the value of this member variable does not have to be serialized with the object. When the class will be de-serialized, this variable will be initialized with a default value of its data type (i.e. zero for integers).

4)What class allows you to read objects directly from a stream?


The ObjectInputStream class supports the reading of objects from input streams.

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

6)How is it possible for two String objects with identical values not to be equal under the == operator? How are this() and super() used with constructors?

The == operator compares two objects to determine if they are the same objects in memory. It is possible for two String objects to have the same value, but located in different areas of memory.

No comments:

Post a Comment

Thanks to given comments.......

My Blog List