when we write class.forName("any one class"); what happens
actually?what it will return?explain stepwise?
Answer Posted / bharat
when we write the statement
Class.forName("fully qualified path for the class");
then the above statement will do the following things:->
1. loads the specified class (if found) in the memory otherwise throws ClassNotFoundException
2. Returns the object of type java.lang.Class corresponding to the class that was loaded ,In actual this returned object contains all properties of the class that was loaded, In technical words we will say that it is the reflection of the actual class, we can now access all the information about the loaded class with the help of this Class class object, we can now access all the data members , member methods whether they are private or public, all constructors, names of its parent classes, parent Interfaces etc with the help of this Class class object.
| Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
explain the difference between jdk and jvm?
Implement a stack with push (), pop() and min() in O(1) time.
What is default constructors?
What do you understand by the term string pool?
What is the difference between the ">>" and " >>>" operators in java?
take an array with -ve and +ve value both.find out the nearest value of 0(zero).if two values are same like(-2 and +2)then extract +2 is nearest of 0(zero).
What is == mean?
What is function and its uses?
What is the major drawback of internal iteration over external iteration?
Does garbage collection occur in permanent generation space in jvm?
How does class forname work in java?
What is difference between throw and throws ?
Can we override final method?
How are variables stored in memory?
What is t in generics in java?