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 are the basics of core java?
What’s the difference between callable and runnable?
What is string in java?
What is a bubble sort in java?
When do we use synchronized methods in java?
Does A Class Inherit The Constructors Of Its Superclass?
What is difference between static and abstract class?
What is use of super keyword in java?
Why convert an applet to an application?
What is linked hashmap and its features?
Does java linked list allow duplicates?
What type of variable is error flag?
how do I create a runnable with inheritance? : Java thread
How many types of methods are there?
What is 32 bit float?