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 are different access specifiers in java? Explain
What is double checked locking in singleton?
What does it mean that a class or member is final?
What is classpath?
Are maps ordered java?
What is callable java?
What is lexicographically smallest string?
What is the difference between char and char *?
Explain the difference between hashmap and hashtable in java?
How do you reverse sort in java?
Can list contain null in java?
What are different type of exceptions in java?
What is JDBC Driver interface?How can you retrieve data from the ResultSet
What happens if we override private method?
What is the use of private static?