Java Reference
In-Depth Information
1. package my.city;
2. import my.school.ClassRoom;
3. public class School {
4. public static void main(String [] args) {
5. System.out.println(ClassRoom.globalKey);
6. ClassRoom room = new ClassRoom(101, “Mrs. Anderson”);
7. System.out.println(room.roomNumber);
8. System.out.println(room.teacherName);
9. }
10. }
which of the following line numbers in main generate a compiler error? (Select all
that apply.)
A. None; the code compiles fine.
B. Line 5
C. Line 6
D. Line 7
E. Line 8
7. Suppose we have the following class named ClassRoom:
1. package my.school;
2. public class ClassRoom {
3. public static int globalKey = 54321;
4. }
Now suppose we have the following class named Administrator:
1. package my.city;
2.
3. public class Administrator {
4. public int getKey() {
5. return globalKey;
6. }
7. }
Which one of the following statements inserted at line 2 of the Administrator class
will make the Administrator class compile successfully?
A. import my.school.ClassRoom;
B. import static my.school.ClassRoom.*;
C. import static my.school.ClassRoom;
D. import static my.school.*;
E. Nothing — the class compiles.
Search WWH ::




Custom Search