Durga's Interview Questions
Durga's Interview Questions
Page 1
Page 2
Page 3
Page 4
Page 5
Page 6
28.What is the relationship between a methods throws clause and the exceptions that can be
thrown during the methods execution?
A methods throws clause must declare any checked exceptions that are not caught within the body of
the method. These exceptions must be handled by the caller.
29. How many ways can an argument be passed to a subroutine?
An argument can be passed in two ways. They are Pass by Value and Passing by Reference.
Passing by value: This method copies the value of an argument into the formal parameter of the
subroutine.
Passing by reference: In this method, a reference to an argument (not the value of the argument) is
passed to the
parameter.
Page 7
Page 8
39. When you serialize an object, what happens to the object references included in the object?
The serialization mechanism generates an object graph for serialization. Thus it determines whether the
included object references are serializable or not. This is a recursive process. Thus when an object is
serialized, all the included objects are also serialized alongwith the original obect.
40. What one should take care of while serializing the object?
One should make sure that all the included objects are also serializable. If any of the objects is not
serializable then it throws a NotSerializableException.
Page 9
Page 10
48.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.
49.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 if your class implements this
interface, you can customize the serialization process by implementing these methods
50.What is the purpose of garbage collection in Java, and when is it used?
The purpose of garbage collection is to identify and discard objects that are no longer needed by a
program so that their resources can be reclaimed and reused. A Java object is subject to garbage
collection when it becomes unreachable to the program in which it is used.
Page 11
Page 12
Page 13
Page 14
Page 15
Page 16
Page 17
Page 18
Page 19
92. What is the class and interface in java to create thread and which is the most advantageous
method?
Thread class and Runnable interface can be used to create threads and using Runnable interface is the
most advantageous method to create threads because we need not extend thread class here.
93. What are the methods for inter-thread communication and what is the class in which these
methods are defined?
wait (), notify () and notifyAll() methods can be used for inter-thread communication and these
methods are in Object class.
wait() : When a thread executes a call to wait() method, it surrenders the object lock and enters into a
waiting state.
notify() or notifyAll() : To remove a thread from the waiting state, some other thread must make a call
to notify() or notifyAll() method on the same object.
94.What is multithreading?
Multithreading is the mechanism in which more than one thread run independent of each other within
the process.
95. What is the difference between process and thread?
Process is a program in execution whereas thread is a separate path of execution in a program.
What is the difference between Array and vector?
Array is a set of related data type and static whereas vector is a growable array of objects and dynamic.
Page 20
100. How many times may an objects finalize() method be invoked by the garbage collector?
An objects finalize() method may only be invoked once by the garbage collector.
101. What modifiers may be used with top-level class?
public, abstract and final,strictfp can be used for top-level class.
102. What is the difference between the Boolean & operator and the && operator?
If an expression involving the Boolean & operator is evaluated, both operands are evaluated. Then the
& operator is applied to the operand. When an expression involving the && operator is evaluated, the
first operand is evaluated. If the first operand returns a value of true then the second operand is
evaluated. The && operator is then applied to the first and second operands. If the first operand
evaluates to false, the evaluation of the second operand is skipped.
Page 21
Page 22