What will be the output of the following Java program? [code] class c { public void main( String[] args )

Ngoc Hue

New member
What will be the output of the following Java program?
Code:
    class c 
    {    
        public void main( String[] args ) 
        {  
            System.out.println( "Hello" + args[0] ); 
        } 
    }
A. Hello c
B. Hello
C. Hello world
D. Runtime Error
 
Answer: d
Explanation: A runtime error will occur owning to the main method of the code fragment not being declared static.
Output:
Code:
$ javac c.java
Exception in thread "main" java.lang.NoSuchMethodError: main
This Section of our 1000+ Java MCQs focuses on Character and Boolean Datatypes of Java Programming Language.
 

Tìm kiếm

Back
Top