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 serialversionuid?
Why do we use bufferedreader?
Why is multithreading important?
What is a singleton in genetics?
What are different types of classloaders?
What is the main purpose of serialization in java?
Explain inner classes ?
What is Major and importance difference between for and foreach loop ?
What is JDBC Driver interface?How can you retrieve data from the ResultSet
what is the constructor and how many types of constructors are used in java?
Can we have return statement in finally clause? What will happen?
Is map sorted in java?
Why are the objects immutable in java?
What is the set interface in java programming?
Is java type safe?