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

For which statements we use a label?

3 Answers   Wipro,


Can you override a final method?

0 Answers  


How to create an immutable class?

0 Answers  


Why is a constant variable important?

0 Answers  


What is the purpose of garbage collection in java? When is it used?

0 Answers  






What is actual difference between statement,prepared statement and callable statement and when we have to use it? pls post a answer with code and clear explanation. thanks

2 Answers  


explain the concept of virtual method invocation in polymorphism in detail?

0 Answers   TCS,


What is scanner in java?

0 Answers  


What does three dots mean in java?

0 Answers  


Can a constructor be protected?

0 Answers  


What does it mean that a class or member is final?

0 Answers  


Name the class that used to read objects directly from a stream?

4 Answers   Wipro,


Categories