Industrial Training

INFOSYS Core Java Campus Interview Question Answer


What is the purpose of assert keyword used in JDK1.4.x?

In order to validate certain expressions. It effectively replaces the if block and automatically throws the AssertionError on failure. This keyword should be used for the critical arguments. Meaning, without that the method does nothing.


How will you get the platform dependent values like line separator, path separator, etc., ?

Using Sytem.getProperty(…) (line.separator, path.separator, …)


What is skeleton and stub? what is the purpose of those?

Stub is a client side representation of the server, which takes care of communicating with the remote server. Skeleton is the server side representation. But that is no more in use… it is deprecated long before in JDK.


What is the final keyword denotes?

final keyword denotes that it is the final implementation for that method or variable or class. You can’t override that method/variable/class any more.


What is the significance of ListIterator?

You can iterate back and forth.


What is the major difference between LinkedList and ArrayList?

LinkedList are meant for sequential accessing. ArrayList are meant for random accessing.


What is nested class?

If all the methods of a inner class is static then it is a nested class.



What is inner class?

If the methods of the inner class can only be accessed via the instance of the inner class, then it is called inner class.>


What is composition?

Holding the reference of the other class within some other class is known as composition.


What is aggregation?

It is a special type of composition. If you expose all the methods of a composite class and route the method call to the composite method through its reference, then it is called aggregation.



What are the methods in Object?

clone, equals, wait, finalize, getClass, hashCode, notify, notifyAll, toString


Can you instantiate the Math class?

You can’t instantiate the math class. All the methods in this class are static. And the constructor is not public.


What is singleton?

It is one of the design pattern. This falls in the creational pattern of the design pattern. There will be only one instance for that entire JVM. You can achieve this by having the private constructor in the class. For eg., public class Singleton { private static final Singleton s = new Singleton(); private Singleton() { } public static Singleton getInstance() { return s; } // all non static methods … }


What is DriverManager?

The basic service to manage set of JDBC drivers.


What is Class.forName() does and how it is useful?

It loads the class into the ClassLoader. It returns the Class. Using that you can get the instance ( “class-instance”.newInstance() ).


What is a Marker Interface?

An interface with no methods. Example: Serializable, Remote, Cloneable


What interface do you implement to do the sorting?

Comparable


What is the eligibility for a object to get cloned?

It must implement the Cloneable interface


What is the purpose of abstract class?

It is not an instantiable class. It provides the concrete implementation for some/all the methods. So that they can reuse the concrete functionality by inheriting the abstract class.


What is the difference between interface and abstract class?

Abstract class defined with methods. Interface will declare only the methods. Abstract classes are very much useful when there is a some functionality across various classes. Interfaces are well suited for the classes which varies in functionality but with the same method signatures.


What do you mean by RMI and how it is useful?

RMI is a remote method invocation. Using RMI, you can work with remote object. The function calls are as though you are invoking a local variable. So it gives you a impression that you are working really with a object that resides within your own JVM though it is somewhere.


What is the protocol used by RMI?

RMI-IIOP


What is a hashCode?

hash code value for this object which is unique for every object.


What is a thread?

Thread is a block of code which can execute concurrently with other threads in the JVM.


What is the algorithm used in Thread scheduling?

Fixed priority scheduling.


What is hash-collision in Hashtable and how it is handled in Java?

Two different keys with the same hash value. Two different entries will be kept in a single hash bucket to avoid the collision.


What are the different driver types available in JDBC?

1. A JDBC-ODBC bridge 2. A native-API partly Java technology-enabled driver 3. A net-protocol fully Java technology-enabled driver 4. A native-protocol fully Java technology-enabled driver For more information: Driver Description


Is JDBC-ODBC bridge multi-threaded?

No


Does the JDBC-ODBC Bridge support multiple concurrent open statements per connection?

No


What is the use of serializable?

To persist the state of an object into any perminant storage device.

Hi I am Pluto.