Multiple Choice Question

Quiz Guidelines

 

QID: 
171
Question: 

What will the following code print?

public class TestClass{
int x = 5;
int getX(){ return x; }
public static void main(String args[]) throws Exception{
TestClass tc = new TestClass();
tc.looper();
System.out.println(tc.x);
}
public void looper(){
int x = 0;
while( (x = getX()) != 0 ){
for(int m = 10; m>=0; m--){
x = m;
}
}
}
}

Select 1 option

A. It will not compile.
B. It will throw an exception at runtime.
C. It will print 0.
D. It will print 5.
E. None of these.

Q&A Set: