Explain class A{}
class B{}
class C{}
all the three classes are saved in a single file name, what
the name should i provide to the file ,in what file name
should i run the program? Ple Explain

Answer Posted / mohammad faisal

The most common answer is: it would be the class name
having the main() method.

If you are using multiple classes in a single file than it
doesn't matter how much the number of classes.
But there is a problem for begienners that by what name
should they save the file.

There is something interesting to java:
You can save the program by any name. i.e.,
Let your program is:
class a
{
}
class b
{
}
class c
{
public static void main(String args[])
{
}
}

Now save the file as Amazing_Example.java

Compile the file as:
c:\>javac Amazing_Example.java
c:\>
This compilation is successfull.
Now you can run the program using the name of class having
the main() method. As in our example class c has the main()
method.
i.e.,
c:\>java c
c:\>//Here will be the output of your code.

Is This Answer Correct ?    4 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

what is a green thread? : Java thread

805


What is the purpose of a parameter?

796


What are filterstreams?

849


What is math in java?

853


difference between byte stream class and character stream class?

4324


Convert Binary tree to linked list.

846


java Technical questions asked by JPMC

4814


How to disable caching on back button of the browser?

769


What does @param args mean in java?

828


What is javac_g?

781


Name four container classes.

770


What is private protected in java?

801


Which java ide is used the most?

773


Write a program to print fibonacci series up to count 10.

714


Which of the classes will have more memory allocated?

751