Q
public class F0091
{
public void main( String[] args )
{
System.out.println( "Hello" + args[0] );
}
}
What will be the output of the program, if this code is executed with the command line:
> java F0091 world
Question Info
Choose the Best Option
Click any option to instantly check if you're correct.
Explanation
Option D is correct. A runtime error will occur owning to the main method of the code fragment not being declared static:
Exception in thread "main" java.lang.NoSuchMethodError: main
The Java Language Specification clearly states: "The main method must be declared public, static, and void. It must accept a single argument that is an array of strings."
Want to remember what you got wrong?
Create a free account in seconds to track your score, revisit mistakes and continue Programming Language where you left off.
- Save your progress & streak
- Topic-wise quizzes & scores
- Bookmark tricky questions
- Printable MCQ sets
Nice — 3 questions done!
Don't lose this streak. Sign up free to save your score and pick up exactly where you stopped.
Share This Question
Challenge a friend or share with your study group.