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

How transient variable is different from volatile variable?

569


What is a lightweight component?

602


What is operator overloading. Is it is supported in java?

528


Difference between Linked list and Queue?

613


Why java is used everywhere?

596






Is arraylist an object in java?

611


Can we create constructor in abstract class ?

587


Is an integer an object?

523


How is hashset defined in java?

525


Can we have more than one package statement in the source file?

647


When should I use stringbuffer?

580


Are registers volatile?

539


How does multithreading take place on a computer with a single cpu in java programming?

541


What purpose do the keywords final, finally, and finalize fulfill?

620


Are true and false keywords?

583