Multiple Choice Question

Quiz Guidelines

 

QID: 
366
Question: 

What will be the result of compiling and running the following code?

class Base{
public Object getValue(){ return new Object(); } //1
}
class Base2 extends Base{
public String getValue(){ return "hello"; } //2
}
public class TestClass{
public static void main(String[] args){
Base b = new Base2();
System.out.println(b.getValue()); //3
}
}

Select 1 option

A. It will print the hash code of the object.
B. It will print hello.
C. Compile time error at //1.
D. Compile time error at //2.
E. Compile time error at //3.

Q&A Set: 

Search the Web

Custom Search

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