File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
http://aspose.com/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


Win a copy of EJB 3 in Action this week in the EJB and other Java EE Technologies forum!
JavaRanch » Java Forums » Java » Beginning Java
Bookmark "Top level classes" Watch "Top level classes" New topic
Author

Top level classes

gauraw gupta
Greenhorn

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.

Thanks
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
Sheriff

Joined: Oct 13, 2005
Posts: 36482
    
  16
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.
 
It is sorta covered in the JavaRanch Style Guide.
 
subject: Top level classes
 
Similar Threads
can a java.lang class be extended using extend ?
Why private isnt private, story about Inner Class.
Traps to be aware of in any SCJP test !!!!! :)
Marcus Green #2 Question 8
Roundup game