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 server side caching?
What are the different types of inner classes?
What is t in generics in java?
Can we have more than one package statement in source file ?
What purpose do the keywords final, finally, and finalize fulfill?
Difference between linkedlist and arraylist.
How do you replace all in word?
how does the run() method in runnable work? : Java thread
Is java a pure object oriented language?
How many types of constructors are used in java?
Is jdk required on each machine to run a java program?
Can a class have multiple subclasses?
What is the basic difference between string and stringbuffer object?
What is member in java?
When do we use synchronized methods in java?