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
Difference between error and exception
How large is a boolean?
Can we use static class instead of singleton?
How does finally block differ from finalize() method?
Is static a singleton?
Can we sort array in java?
What is the final method?
What language is an assembler written in?
What is array pointers ?
Can a source file contain more than one class declaration?
Is null a value?
What is stack class in java?
What is the use of conditional statement?
How to remove the trailing spaces from a string?
What is flag in java?