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
What is serialversionuid?
Does java return by reference?
What are the advantages of java inner classes?
What are reference variables in java?
What is purpose of find feature?
Difference between association, composition and aggregation?
Is object a data type?
what is bmg file and how to create that files?what will it contailn?
What do you understand by java virtual machine?
Is it possible to use string in the switch case?
What are keywords give examples?
How do you trim a space in java?
How do I remove a character from a string in java?
Why are arrays useful in java?
What is the use of hashmap in java?