class test
{
private static void main(String []adsf)
{

}
}

explain me that the above code is error or exception

Answers were Sorted based on User's Feedback



class test { private static void main(String []adsf) { } } explain me that the above ..

Answer / bhargava

Code will throw exception. Because usually every stand
alone program execution should start with main method. It
should be public other wise this method doesnt exposed to
out side to run.

Is This Answer Correct ?    12 Yes 0 No

class test { private static void main(String []adsf) { } } explain me that the above ..

Answer / sri

It will not generate any compile time error, but while
running the program it will generate the output as "main
method is not public".....

Is This Answer Correct ?    7 Yes 0 No

class test { private static void main(String []adsf) { } } explain me that the above ..

Answer / xavier

This will throw a runtime error stating main method not public
This is because main method is the starting point of program
execution and it should be accessible by JVM

Is This Answer Correct ?    2 Yes 0 No

Post New Answer

More Core Java Interview Questions

What are java methods?

0 Answers  


What are the drawbacks of reflection?

0 Answers  


What is the difference between call by reference and call by pointer?

0 Answers  


What is an exception in java?

0 Answers  


Can we execute a program without main?

0 Answers  






System.out.println(101/14) what is the output? a)6 b)14 c)7.14 d)0

8 Answers   Accenture,


What is the final keyword?

0 Answers  


What is mean by exception?

0 Answers  


What are field variable and local variable?

3 Answers  


what state does a thread enter when it terminates its processing? : Java thread

0 Answers  


What is void in java?

0 Answers  


What is keyword and identifier?

0 Answers  


Categories