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 are the limitations of procedural programming approach?

758


What is passing parameters in java?

732


Explain the use of sublass in a java program?

776


How many types of keywords are there?

766


How do you call a reference in java?

707


Why is String immutable?

837


Why static functions are used?

799


What is string [] java?

738


What does g mean in regex?

751


What is the best definition for data?

722


What is Java Shutdown Hook?

839


What is the difference between integer parseint and integer valueof?

765


How do you compare arrays in java?

715


Is list thread safe in java?

705


What is multithreading in java?

785