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 importance of finally block in java?
explain copyonwritearraylist and when do we use copyonwritearraylist?
You're given a Boolean 2D matrix, can you find the number of islands?
Can a class with private constructor be extended?
What is empty string literal in java?
Can memory leak in java?
What are the two main uses of volatile in Java?
Can set contain duplicates?
when should you use stringbuilder class in a program?
Which graphs are functions?
Can vector have duplicates in java?
What is use of set in java?
what do you mean by marker interface in java?
What is the full form of jpeg?
Which data type is class in java?