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 / bhavya
Since main method is made private JVM does not find the main class, so it says there is no main method.
| Is This Answer Correct ? | 1 Yes | 0 No |
Post New Answer View All Answers
Where are the local variables stored?
What is string syntax?
Can we create constructor in abstract class ?
What is a lambda expression ? What's its use ?
What are parsing rules?
Why do we need data serialization?
What is the difference between I ++ and ++ I in java?
Can You Have Virtual Functions In Java?
What are the types of web technologies?
Why super is first line in java?
Differentiate between the constructors and methods in java?
What is reflexive association?
What is final keyword in java? Give an example.
Why put method is used?
Why is the main method declared static?