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 / kumaresan.r

Hai,
When you compile program it will run with out error,bt it
did not show the value of high,low,underflow.it just show that

"Main method not public.

Process completed.".

So we cant say that this is an output.

Is This Answer Correct ?    15 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is encapsulation in java?

618


Can set contain duplicates?

538


Why are getters and setters used?

564


How do you decide when to use arraylist and linkedlist?

530


Can we start a thread twice in java?

506






Why is java called java?

539


What is comparator in java?

549


Is stringwriter thread safe?

548


What happens if an exception is throws from an object's destructor?

579


What is number data type in java?

548


How can you make sure that your singleton class will always return single instance in multi-threaded environment?

566


Give few examples of final classes defined in Java API?

698


What is a class instance variable?

614


What is the difference between exception and error in java?

486


Which is better list or arraylist in java?

490