Multiple Choice Question

Quiz Guidelines

 

QID: 
443
Question: 

What would be the result of attempting to compile and run the following program?

class TestClass{   
static TestClass ref;   
String[] arguments;   
public static void main(String args[]){      
ref = new TestClass();      
ref.func(args);   }   
public void func(String[] args){      
ref.arguments = args;   } }

Select 1 option

A. The program will fail to compile, since the static method main is trying to call the non-static method func. 
B. The program will fail to compile, since the non-static method func cannot access the static member variable ref. 
C. The program will fail to compile, since the argument args passed to the static method main cannot be passed on to the non-static method func. 
D. The program will fail to compile, since method func is trying to assign to the nonstatic member variable 'arguments' through the static member variable ref. 
E. The program will compile and run successfully.

Q&A Set: