aspose file tools
The moose likes Beginning Java and the fly likes Top level classes Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Top level classes" Watch "Top level classes" New topic

Top level classes

gauraw gupta

Joined: Apr 10, 2011
Posts: 5
Which is the top level class either Class java.lang.Object or Class java.lang.Object or Class java.lang.Class and please can you explain me the Classloader works.

Gauraw Kumar Gupta
Ashutosh Limaye
Ranch Hand

Joined: Oct 24, 2005
Posts: 58
java.lang.Object is the supermost class. Classloader is a class itself in the java.lang package. It contains a method called loadClass(String classname) which is also overloaded as loadClass(String name,boolean resolve). The JVM would instantiate the Classloader when it is created (That's how java.lang is imported by default). Then whenever a class which is not there on the heap is referred to by the code, the JVM calls the loadClass method and pass the name of the class as the argument.
But this may not actually load the .class file in the heap, it may simply locate the desired class and create a Class class object for it (which is the meta-data). When the object of the desired class needs to be created, the JVM may call the loadClass method with name=[classname ] and resolve=[true] this will make the loadClass method call the defineClass() method which contains the magic of creating the in memory image of the .class file.
Hope this helps please read the white paper on ClassLoader for further details....
Campbell Ritchie

Joined: Oct 13, 2005
Posts: 41576
Both are top level classes. You have misunderstood what top level class means. It means a class which is not inside another class.
You should have a look at the Java™ tutorials, where you find out about the Object class; that second link will give you some useful information, too.
There isn't much about class loaders in the Java™ Tutorials, but you can doubtless find lots by Googling.
wood burning stoves
subject: Top level classes