answersLogoWhite

0


Best Answer

You can only have one non-inner public classes per java file and that class name must match the filename. The java file can also have any number of inner classes and anonymous classes.

User Avatar

Wiki User

11y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How many classes should be included in each java file?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What is the meaning of import in java program?

It tells the compiler where to find classes that are outside the file you are editing.It tells the compiler where to find classes that are outside the file you are editing.It tells the compiler where to find classes that are outside the file you are editing.It tells the compiler where to find classes that are outside the file you are editing.


Where you can include a header file in the program?

You can include a file with the #include directive at any place you want to. You just have to consider that the compiler will see the total source file as if you had copied the contents of each include file at the point where you included it, and it will parse and process the total source file accordingly. That said, header files, a subset of included files, are generally #include'd at the top of the source file. Again, it all depends on what is in the include file.


What does the import java.io. file class do?

It gives you access to all of the IO file classes, including all of the stream classes and java.io.File.


What are filestream classes in c plus plus?

The file stream classes (ifstream and ofstream) are derivatives of the I/O stream classes (istream and ostream) that are specific to file input and output.


If you have two public classes in a java file what will be the error and how will you remove it?

Hmm, let me see, it is technically perfectly legal to have 2 classes in a single file, as long as one class is an inner class of the other: i.e. public class Stevo{ public class Fun{}}. But if you want two separate classes independent of each other the compiler would scream at you about class is public and should be declare in a file named [className].java. To fix this simply follow the compiler's instructions (shocking! the compiler actually was clear about something) and create a new file with the given name. But sometimes an inner class would be helpful, i.e. an iterator for the Abstract Data Type you are implementing.

Related questions

What should be included in your float plan for a weekend trip?

If you file a float plan for a weekend trip, names and addresses of passengers should be included in the plan.


What is the meaning of import in java program?

It tells the compiler where to find classes that are outside the file you are editing.It tells the compiler where to find classes that are outside the file you are editing.It tells the compiler where to find classes that are outside the file you are editing.It tells the compiler where to find classes that are outside the file you are editing.


Where you can include a header file in the program?

You can include a file with the #include directive at any place you want to. You just have to consider that the compiler will see the total source file as if you had copied the contents of each include file at the point where you included it, and it will parse and process the total source file accordingly. That said, header files, a subset of included files, are generally #include'd at the top of the source file. Again, it all depends on what is in the include file.


What does the import java.io. file class do?

It gives you access to all of the IO file classes, including all of the stream classes and java.io.File.


What are filestream classes in c plus plus?

The file stream classes (ifstream and ofstream) are derivatives of the I/O stream classes (istream and ostream) that are specific to file input and output.


Can you file bankruptcy on your house after chapter 7 discharge?

Your mortgage should have been included in your chapter 7 discharge. If it was- then you are no longer liable for the mortgage, but the lender can still foreclose on the property. If the mortgage was not included- then why wasnt it included.


How do you get blood alcohol test results from a DUI arrest?

It should have been included with your arrest report, or your attorney can file for discovery.


What header file should be included if you are to develop a function that can accept variable number of arguments?

stdarg.h Before my original answer was removed and replaced with the above I suggested. Read the manual for your compiler the header files for each compiler are different. None of the compilers I currently use have a header file called "stdarg.h" but do have "varargs.h"


Can a .java file contain more than one java classes?

Yes, it can. However, there can only be one public class per .java file, as public classes must have the same name as the source file.


What is included in the title bar?

the file name


If you have two public classes in a java file what will be the error and how will you remove it?

Hmm, let me see, it is technically perfectly legal to have 2 classes in a single file, as long as one class is an inner class of the other: i.e. public class Stevo{ public class Fun{}}. But if you want two separate classes independent of each other the compiler would scream at you about class is public and should be declare in a file named [className].java. To fix this simply follow the compiler's instructions (shocking! the compiler actually was clear about something) and create a new file with the given name. But sometimes an inner class would be helpful, i.e. an iterator for the Abstract Data Type you are implementing.


Should one take tax classes before doing business taxes?

You should definitely look into getting an accountant or go to these classes because they have very many different tax laws. if you file anything wrong, the IRS can come back and make you pay for it.