Q-3:-is it possible to write main() in multiple class of .java file?
Ans:yes,it is possible to write the main() in multiple class.
FOR EX:-
demo.java
class hello
{
public static void main(String[]args)
{
System.out.println("hii hello");
}
}
class test
{
public static void main(String[]args)
{
System.out.println("hii test");
}
}
output:
1)compile the program
javac demo.java
2)To run the program
java hello
hii hello
2)to run the program using test class
java test
hiii test
Nice blogs very helpful questions
ReplyDelete