Sail E0 Webinar
Question


What is the output of this program?


class c {
public void main( String[] args )
{
System.out.println( "Hello" + args[0] );
}
}
Options:
A .  Hello c
B .  Hello
C .  Hello world
D .  Runtime Error.
Answer: Option D

A runtime error will occur owning to the main method of the code fragment not being declared static.
Output:
$ javac c.java
Exception in thread "main" java.lang.NoSuchMethodError: main




Was this answer helpful ?
Next Question

Submit Solution

Your email address will not be published. Required fields are marked *

Latest Videos

Latest Test Papers