Given the following class definitions:
Public abstract class A2{
private int x;
public A2 (int a) {
this.x=a;
}
public int getX(){
return this.x;
}
public abstract double sameInfo();
}
public class B2 extends A2 {
private int y;
public B2 (int a, int b) {
super(a);
this.y = b;
}
public int getY () {
return this.y;
}
public double someInfo () {
return 100 * y;
}
}
public class C2 extends A2 {
private int z;
public C2 (int z){
super(5);
this.z=z;
}
public int getZ() {
return this.z;
}
public double sameInfo() {
return 100 * z * getZ();
}
}
public class D2 extends B2 {
public D2 (int D) {
super(10,20);
}
public double sameInfo () {
return 100 * getY() * getX();
}
}
You may assume that the following statements precede those in the table below:
A2 a1, a2 = new B2(2, 4);
B2 b1, b2 = new B2 (4, 6);
C2 c1, c2 = new C2 (5);
D2 d1, d2 = new D2 ();
1- The following statement:
b1= new A2(10);
Answer
A. Produce no error
B. Produces a SYNTAX (or compile-time) error
C. Produces an EXCEPTION (or run-time error)
D. Produces a LOGIC error
2- The following statement:
b2 = new D2();
Answer
A. Produce no error
B. Produces a SYNTAX (or compile-time) error
C. Produces an EXCEPTION (or run-time error)
D. Produces a LOGIC error
3- The following statement:
a2.getY();
Answer
A. Produce no error
B. Produces a SYNTAX (or compile-time) error
C. Produces an EXCEPTION (or run-time error)
D. Produces a LOGIC error
4- The following statement:
a2.someInfo();
Answer
A. Produce no error
B. Produces a SYNTAX (or compile-time) error
C. Produces an EXCEPTION (or run-time error)
D. Produces a LOGIC error
5- The following statement:
((D2)b2).getY();
Answer
A. Produce no error
B. Produces a SYNTAX (or compile-time) error
C. Produces an EXCEPTION (or run-time error)
D. Produces a LOGIC error
6- The following statement:
d1 = new B2(5,6);
Answer
A. Produce no error
B. Produces a SYNTAX (or compile-time) error
C. Produces an EXCEPTION (or run-time error)
D. Produces a LOGIC error