What is a compile-time error or run-time error


Complete the mcq:

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);

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();

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();

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();

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();

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);

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.

Solution Preview :

Prepared by a verified Expert
C/C++ Programming: What is a compile-time error or run-time error
Reference No:- TGS01934263

Now Priced at $25 (50% Discount)

Recommended (91%)

Rated (4.3/5)