Hi all, I am reading a bit about inheritance, super classes and subclasses. Now when I build a java program I usually have a java file for the class and another one to test the class. I was wondering if I use a superclass and a subclass, should they be in the same file or in 2 different files?
thanks
Violet_82
89
Posting Whiz in Training
Recommended Answers
Jump to PostIt would depend on just what you are doing, but generally speaking, you would have them in separate files. Keep in mind that you can only have a single public class in a file.
Jump to PostViolet: you basically answered that question by each and every class you've written so far. all classes extend the Object class, but I pretty much doubt you'll write your classes in the Object.class code, right?
all that is needed for your class to extend a class, is that that class …
All 7 Replies
Schol-R-LEA
1,446
Commie Mutant Traitor
Featured Poster
stultuske
1,116
Posting Maven
Featured Poster
Violet_82
89
Posting Whiz in Training
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
Violet_82
89
Posting Whiz in Training
JamesCherrill
4,733
Most Valuable Poster
Team Colleague
Featured Poster
Violet_82
89
Posting Whiz in Training
Be a part of the DaniWeb community
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.