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
What is stack class in java?
What is the difference in between cpp and java? Can u explain in detail?
What is the purpose of using javap?
How many characters is 16 bytes?
What are the four pillars of java?
Explain jvm, jre, and jdk?
Can we sort set in java?
How many bits is a word?
Explain some best practices you would apply while using collection in java?
Can we define private and protected modifiers for variables in interfaces?
Explain when noclassdeffounderror will be raised ?
Can we have more than one package statement in the source file?
What are the wrapped, classes?
What is xslt in java?
Is string a class in java?