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

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 to create and run runnable jar file of a Java Project.

4 Answers   TCS, Wipro, US Consulate, HCL, Tech Mahindra,


Why we r using String args[] in main() even though v r not passing any arguments in command line?

2 Answers  


1+(2*3)+(4*5*6)+(7*8*9*10)+... specified input value

1 Answers   MAQ,






Bubble Sort. java thereafter the user will be asked to inpout the size of the list,sort the list in ascending order and display the sorted list in a horizontal manner???

0 Answers  


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

0 Answers  


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

0 Answers  


is public static void main() work in java?is "String arg[]" needed as argument?

4 Answers   Tech Mahindra,


write a program that will ask the user to enter a number n and display the product of all numbers from 1 to n.

1 Answers  


Program to print map of India in java.

2 Answers  


Design a program using one-dimensional array that determines the highest value among the eight input values from a user. Display the difference of each value from the highest to the lowest.

1 Answers   RoboSoft,






Categories