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

Answers were Sorted based on User's Feedback



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

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 ?    2 Yes 3 No

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

Answer / abcd

First of all an in appropriate main method will not cause any
compile time error, it results in a runtime exception.
i think reason is ase all know java program can run usingg
the same name as class name."String args[]" takes program
name as first argument that's why it gives run time exception.

Is This Answer Correct ?    0 Yes 6 No

Post New Answer

More J2SE Code Interview Questions

what is runtime class?

0 Answers   MAQ,


write a program that inputs two real numbers then exchanges their values.

7 Answers   Infosys,


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  


In java, why do we set thread priority, when we know that there is no guarantee by which a thread should be execute?

0 Answers   Google, Microsoft,


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,






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,


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

1 Answers   IBM,


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

0 Answers   Aricent,


write a c program which takes 20 numbers in an array as input from user and rearrange them in two different array defining even or odd

0 Answers  


how to store and retrive a set of values without using an array

8 Answers   FCS, HCL, Maximus,


Is there any static classes are in java give some examples

0 Answers  


Categories