Why the program getting error if we don't use String args[]
in main(), even in the case of not getting any arguments
from command line?



Why the program getting error if we don't use String args[] in main(), even in the case of not..

Answer / mehtaashish

First of all an in appropriate main method will not cause any
compile time error, it results in a runtime exception. The
reason for this is that the main method's signature is written
as such in Java specification. And all the interpreters and
compiler and constructed while keeping language specification
in mind. So whenever we try to run a program JVM looks for
"public static void main(String args[])" for starting
execution. And if it does not find any main method, it throws
the "NoClassDefFoundException".

Is This Answer Correct ?    5 Yes 0 No

Post New Answer

More J2SE Code Interview Questions

For printing a message we use System.out.println in normal programs. We use String msg="text....."; Can't we use String msg=" " in normal programs and System.out.println("........") in applets. Please answer this question?

0 Answers  


How to create Date method to set the date in Ms Access

0 Answers  


what are the other loops except for for,while,do while and until?

0 Answers   Aricent,


Program to print map of India in java.

2 Answers  


inner join,outerjoin,trigger,stored procedure explain with code snippets?

1 Answers   IBM,






How can we get the details for printing the employee details at run time using JDBC connectivity? can u provide the coding for that? Its urgent?

2 Answers  


How Can I Trace A Java Program . Please Give Me Step by Step Process

1 Answers   IBM,


Can we run Applet in Web browser with security policy files

0 Answers  


how to print a message to console without using main() function?(do not use even static blocks also.)

14 Answers   Google, Zoho,


write a program in java to find the moving average of all prime numbers between 2 and 100.

0 Answers  


Is there any static classes are in java give some examples

0 Answers  


A game that has five levels of play has the score for each level stored in an array. You are to write a program that goes through that array and finds: a) the minimum score, and the level at which it occurred b) the maximum score, and the level at which it occurred c)the average score for all five levels The score data you must use for this program are as follows: Game Level Score 1 450 2 316 3 148 Stack implementations is mandatory.

0 Answers  


Categories