Meaningless Drivel is fun!*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes subclass question Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "subclass question" Watch "subclass question" New topic
Author

subclass question

Mike Cunningham
Ranch Hand

Joined: Nov 14, 2000
Posts: 129
Is it true that all classes that we create are subclasses since all programs automatically import the java.lang package?
Someone I work with said this was wrong since sometimes he is able to compile a class without the java.lang import and other times, it is required.
Please Clarify. Thanks.
Guoqiao Sun
Ranch Hand

Joined: Jul 18, 2001
Posts: 317
Hi, Mike :
Java compiler will automatically import java.lang.*;
And all class we create are subclass of Object.
Regards,

------------------
Guoqiao Sun
Sun Certified Programmer for Java™ 2 Platform
try my mock exam¹²³ at my homepage.


Guoqiao Sun<br />SCJP2 SCWCD2<br />Creator of <a href="http://www.jiris.com/" target="_blank" rel="nofollow">www.jiris.com</a>, Java resource, mock exam, forum
Guoqiao Sun
Ranch Hand

Joined: Jul 18, 2001
Posts: 317
Forget one point, the compiler will automatically import java.lang.*; That does not mean it will automatically import every sub package in lang. Example:
import java.lang.reflect.InvocationTargetException;
if you want to use the above class, you should import it explicitly although it is inside lang.
Regards,
------------------
Guoqiao Sun
Sun Certified Programmer for Java™ 2 Platform
try my mock exam¹²³ at my homepage.
Fei Ng
Ranch Hand

Joined: Aug 26, 2000
Posts: 1242
what do u mean "Is it true that all classes that we create are subclasses since all programs automatically import the java.lang package? "
All classes that we create are subclasses since..
subclasses of ???
I dont think automatically import the java.lang got anything
to do with classes we create are subclasses.
???
Marilyn de Queiroz
Sheriff

Joined: Jul 22, 2000
Posts: 9053
    
  12
It is true that all classes that we create are subclasses (of class Object), and it is true that the java.lang package is automatically imported every time (although the subpackages are not automatically imported).

However, it is not true that "all classes that we create are subclasses since all programs automatically import the java.lang package" because these two statements are unrelated.

JavaBeginnersFaq
"Yesterday is history, tomorrow is a mystery, and today is a gift; that's why they call it the present." Eleanor Roosevelt
Mike Cunningham
Ranch Hand

Joined: Nov 14, 2000
Posts: 129
So, does a class need to 'extend' another class to officially be a subclass?
 
I agree. Here's the link: http://aspose.com/file-tools
 
subject: subclass question