Sunday, March 30, 2008

CORE JAVA FAQS

31. What are steps involved in loading of a class file into JVM?

· Produce a stream of binary data that represents the type.

· Parse the stream of binary data into internal data structures in the method area.

· Create an instance of class java.lang.Class that represents the type.


32.Is it possible to detect a malformed class file during early loading by the class loader?

No it is not possible. If a class loader encounters a missing or malformed class file during early loading, it must wait to report that error until the class is first active use by the program.

33.What are the different stages of linking after the class is loaded?

Verification, prepare and resolve are the three phases of linking.


34. What is verification stage and what are steps involved during verification?

It ensures that the types obey the semantics of java language and doesn’t violate the integrity of JVM.

The entire process of detecting any kind of problem with loaded types is placed under the category of verification.

Verification of symbolic references and converting them to direct references.

· checking that final classes are not sub classed

· checking that final methods are not overridden

· if the type being checked is a non-abstract class, checking that all the methods declared in any
interfaces implemented by the class are indeed implemented by the class

· Making sure no incompatible method declarations (such as two methods that have the same name, the same number, order, and types of parameters, but different return types) appear between the type and its supertypes.

35. What is done during Preparation Stage?


The Java Virtual Machine allocates memory for the class variables and sets them to default initial values. The class variables are not initialized to their proper initial values until the initialization phase.

Java Virtual Machine implementations may also allocate memory for data structures that are intended to improve the performance of the running program.

0 comments: