I declared main() method as private. But it still running
and displaying the output. Please Answer it .
Code Snippet as Below:
import java.io.*;
class over
{
private static void main(String[] args)
{
int high = Integer.MAX_VALUE;
int overflow = high + 1;
int low = Integer.MIN_VALUE;
int underflow = low - 1;
System.out.println(high + "\n" +overflow +"\n"+
low +"\n"+underflow);
//System.out.println(overflow);
//System.out.println(low);
//System.out.println(underflow);
}
}
Answer Posted / surendar
hi, Pranav Kumar.
"MAIN METHOD NOT PUBLIC" it isn't output.
When u compile the programe, compiler checks only the syntax errors, variable defination, method prototype etc.
So here compiler doesn't check method prototype weather method
is public or private.
But JVM checks, so to be called by the JVM that method must be public.
| Is This Answer Correct ? | 9 Yes | 0 No |
Post New Answer View All Answers
What is a consumer in java?
Is Constructor possible in abstract class in java ?
Can a class be private?
What is the difference between the final method and abstract method?
What is module in project?
Can you sort a list in java?
What are the advantages of user defined functions?
Why java doesn’t support multiple inheritances?
What is xslt in java?
What is java in detail?
Can we overload final method in java?
How do you generate random numbers in java?
What are methods in java?
What is member in java?
What is difference between ++ I and I ++ in java?