What happens when a main method is declared as private?
Answer Posted / sachin
JVM wants to execute the class its starting Execution from main Method means if JVM wants to execute main method if we declare main Method as private then its restriction the scope of main method if we declare Main Method as public then only jvm can applicable to access the main Method.
for e.g
class SE3
{
private static void main(String[] args)
{
System.out.prinln("Hello");
}
}
E:A_coreResearch_Programs>javac SE3.java
E:A_coreResearch_Programs>java SE3
Error: Main method not found in class SE3, please define the main method as
public static void main(String[] args)
or a JavaFX application class must extend javafx.application.Application
Is This Answer Correct ? | 0 Yes | 0 No |
Post New Answer View All Answers
How to compare strings in java?
Is java se free?
What are the two categories of data types in the java programming language?
Explain wrapper classes in java?
What type of language is java?
Differentiate between class and structure.
Is null or empty java?
Why do we create threads in java?
What is meant by binding in rmi?
What is an immutable class? How to create an immutable class?
Explain heap sort?
Give an example of call be reference significance.
How do you start a thread?
How many arguments can be passed to main ()?
Give differences between Quicksort &Mergesort. When should these sorts be used andwhat is their running time in java?