Language Fundamentals

Q1:
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

A Hello

B Hello Foo91

C Hello world

D The code does not run.

ANS:A - Hello

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.'



img not found
img

For help Students Orientation
Mcqs Questions

One stop destination for examination, preparation, recruitment, and more. Specially designed online test to solve all your preparation worries. Go wherever you want to and practice whenever you want, using the online test platform.