Multiple Choice Question

Quiz Guidelines

 

QID: 
35
Validated against: 
java8
Question: 

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

Select 1 option

class Base{

public short getValue(){ return 1; } //1

}

class Base2 extends Base{

public byte getValue(){ return 2; } //2

}

public class TestClass{

public static void main(String[] args){

Base b = new Base2();

System.out.println(b.getValue()); //3

}

}

A. It will print 1

B. It will print 2.

C. Compile time error at //1

D. Compile time error at //2

E. Compile time error at //3

Q&A Set: