Multiple Choice Question

Quiz Guidelines

 

QID: 
310
Question: 

What will the following program print when compiled and run?

class Data {
private int x = 0;
private String y = "Y";
public Data(int k){
this.x = k;
}
public Data(String k){
this.y = k;
}
public void showMe(){
System.out.println(x+y);
}
}public class TestClass {
public static void main(String[] args) throws Exception {
new Data(10).showMe();
new Data("Z").showMe();
}
}

Select 1 option

A. 0Z
10Y
B. 10Y
0Z
C. It will not compile.
D. It will throws an exception at run time.

Q&A Set: