Multiple Choice Question

Quiz Guidelines

 

QID: 
457
Question: 

What is the result of compiling and running the following code?

public class TestClass{
static int si = 10;
public static void main (String args[]){
new TestClass();
}
public TestClass(){
System.out.println(this);
}
public String toString(){
return "TestClass.si = "+this.si;
}   }

Select 1 option

A. The class will not compile because you cannot override toString() method.
B. The class will not compile as si being static, this.si is not a valid statement.
C. It will print TestClass@nnnnnnnn, where nnnnnnn is the hash code of the TestClass object referred to by 'this'.
D. It will print TestClass.si = 10;
E. None of the above.

Q&A Set: 

Search the Web

Custom Search

Searches whole web. Use the search in the right sidebar to search only within javajee.com!!!