Tuesday, September 16, 2008

Core Java Interview Questions Part-6

76 Q What do you mean by immutable ? How to create an immutable object ?

Immutability means an object cannot be modified after it has been initialized. There will not be any setter methods in an immutable class. And normally these classes will be final.

77 Q What is class loader in java ?

A class loader is a class that is responsible for loading the class. All JVM contains one class loader called primordial class loader.

78 Q What is a weak reference ?

A weak reference is the one that does nor prevent the referenced object from being garbage collected. The weak reference will not keep the object that it refers to alive. A weak reference is not counted as a reference in garbage collection. This will make the memory use more effective.

79 Q What is object cloning?

It is the process of duplicating an object so that two identical objects will exist in the memory at the same time.

80 Q What is object pooling?

Creating a large number of identical short lived objects is called object pooling. This helps to minimize the need of garbage collection and makes the memory use more effective.

81 Q What is garbage collection?

Garbage collection is the process of releasing memory used by unreferenced objects. It relieves the programmer from the process of manually releasing the memory used by objects .

82 Q What is the disadvantage of garbage collection? A

It adds an overhead that can affect performance. Additionally there is no guarantee that the object will be garbage collected.

83 Q What is a Dictionary?

Dictionary is a parent class for any class that maps keys to values., In a dictionary every key is associated with at most one value.

84 Q What is JAR file ?

JAR stands for Java Archive. This is a file format that enables you to bundle multiple files into a single archive file. A jar file will contains a file inside META-INF folder that describes the version and other features of jar file.

85 Q Why Java is not fully objective oriented ?

Due to the use of primitives in java, which are not objects.

86 Q What is a marker interface ?

An interface that contains no methods. Eg: Serializable, Cloneable, SingleThreadModel etc. It is used to just mark java classes that support certain capability.

87 Q What are tag interfaces?

Tag interface is an alternate name for marker interface.

88 Q What are the restrictions placed on static method ?

We cannot override static methods. We cannot access any object variables inside static method. Also the this reference also not available in static methods.

89 Q What is JVM?

JVM stands for Java Virtual Machine. It is the run time for java programs. All are java programs are running inside this JVM only. It converts java byte code to OS specific commands. In addition to governing the execution of an application's byte codes, the virtual machine handles related tasks such as managing the system's memory, providing security against malicious code, and managing multiple threads of program execution.

90 Q What is JIT?

JIT stands for Just In Time compiler. It compiles java byte code to native code.

No comments:

My Ad