Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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);
}
}

Answers were Sorted based on User's Feedback



I declared main() method as private. But it still running and displaying the output. Please Answer..

Answer / 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

I declared main() method as private. But it still running and displaying the output. Please Answer..

Answer / 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

I declared main() method as private. But it still running and displaying the output. Please Answer..

Answer / ravi ranjan

OUTPUT = NO SUCH A METHOD EXCEPTION
REGION= MAIN METHOD MUST BE PUBLIC BECAUSE IT CALLED BY THE
DEMON THREAD

Is This Answer Correct ?    1 Yes 0 No

I declared main() method as private. But it still running and displaying the output. Please Answer..

Answer / 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

More Core Java Interview Questions

Are private methods final?

0 Answers  


Is Java Platform Independent if then how?

5 Answers  


What is variable and constant explain with example?

0 Answers  


Explain about fail safe iterators in java?

0 Answers  


How do you allocate memory to object?

0 Answers  


What is user defined exception in Java?

0 Answers   TCS,


What is the base class of all exception classes in java?

0 Answers  


Explain about core java?

0 Answers  


Can you explain the private protected field modifier?

0 Answers  


What is method overloading in JAVA? Why is it not present in C ?

0 Answers   Akamai Technologies,


Is java free for businesses?

0 Answers  


What is threaded programming and when is it used? : Java thread

0 Answers  


Categories