What happens when a main method is declared as private?

Answer Posted / dharma

main method signature must be like

public static void main(String args[])

if we declare as private then it compiles successfully

but at Runtime it says

"Main method not found in class"

Is This Answer Correct ?    1 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is an exception in java?

638


How to stop a thread in java? Explain about sleep () method in a thread?

574


What is java thread dump, how can we get java thread dump of a program?

561


What is the primitive type short?

572


In Java list the methods that can be overridden?

564






Is null a keyword in java?

550


What is public/private protected in java?

536


Explain the private protected method modifier?

538


Can you give few examples of final classes defined in java api?

555


What does the string method compareto () do?

534


Can an interface implement another interface?

564


What is static keyword in java?

545


Are primitives objects?

557


What is the difference between replace and replace all?

464


Does constructor be static?

560