Consider the following partial class definitions: public class A1 { public int x; private int y; protected int z; . }


Consider the following partial class definitions:
public class A1 {
public int x;
private int y;
protected int z;
.
}
public class A2 extends A1 {
protected int a;
private int b;
.
}
public class A3 extends A2 {
private int q;
.
}
1) Which of the following is true with respect to A1, A2 and A3?
A) A1 is a subclass of A2 and A2 is a subclass of A3.
B) A3 is a subclass of A2 and A2 is a subclass of A1.
C) A1 and A2 are both subclasses of A3.
D) A2 and A3 are both subclasses of A1.
E) A1, A2 and A3 are all subclasses of the class A.
2) Which of the following lists of instance data are accessible in class A2?
A) x, y, z, a, b.
B) x, y, z, a.
C) x, z, a, b.
D) z, a, b.
E) a, b.
3) Which of the following lists of instance data are accessible in A3?
A) x, y, z, a, b, q.
B) a, b, q.
C) a, q.
D) x, z, a, q.
E) x, a, q.
4) Which of the following is true regarding the use of instance data y of class A1?
A) It is accessible in A1, A2 and A3.
B) It is accessible in A1 and A2.
C) It is accessible only in A1.
D) It is accessible only in A3.
E) It is not accessible to any of the three classes.
5) The instruction super(does which of the following?
A) calls the method super as defined in the current class.
B) calls the method super as defined in the current class’parent class.
C) calls the method super as defined in java. lang.
D) calls the constructor as defined in the current class.
E) calls the constructor as defined in the current class’parent class.
6) Aside from permitting inheritance, the visibility modifier protected is also used to:.
a) permit access to the protected item by any class defined in the same package.
b) permit access to the protected item by any static class.
c) permit access to the protected item by any parent class.
d) ensure that the class can not throw a NullPointerException.
e) define abstract elements of an interface.
7) Which of the following is an example of multiple inheritance?
A) A computer can be a mainframe or a PC.
B) A PC can be a desktop or a laptop.
C) A laptop is both a PC and a portable device.
D) A portable device is a lightweight device.
E) Macintosh and IBM PC are both types of PCs.
8) Java does not support multiple inheritance, but some of the abilities of multiple inheritance are available by:.
a) importing classes.
b) implementing interfaces.
c) overriding parent class methods.
d) creating aliases.
e) using public rather than protected or private modifier.
9) Abstract methods are used when defining:.
a) interface classes.
b) derived classes.
c) classes that have no constructor.
d) arrays.
e) classes that have no methods.


Leave a Reply

Your email address will not be published. Required fields are marked *