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 is the final access modifier in java?

0 Answers  


Why scanner is used in java?

0 Answers  


What is the diffrence between inner class and nested class?

0 Answers  


What is the relationship between class and object?

0 Answers  


What is the difference between static and non-static variables?

6 Answers  






What is ph and buffers?

0 Answers  


Suppose i have two threads t1 and t2 are running.How the main thread will know that the two threads t1,t2 execution has completed?

2 Answers   Subex,


How do you define a set in java?

0 Answers  


Are primitives objects?

0 Answers  


What does flagged out mean?

0 Answers  


How is java created?

0 Answers  


Is a class an object?

0 Answers  


Categories