Java Reference
In-Depth Information
A. In Parent
B. In Child
C. 0.0
D. null
E. The code does not compile.
16. Given the following class definition:
1. import java.awt.Dimension;
2. public class Shipment {
3. public static class Box {
4. public Dimension dimension;
5. public int depth;
6.
7. public Box(Dimension d, int x) {
8. dimension = d;
9. depth = x;
10. }
11.
12. private int getVolume() {
13. return dimension.height * dimension.width * depth;
14. }
15. }
16.
17. public Box box;
18.
19. public void go() {
20. System.out.println(box.getVolume());
21. }
22.}
what is the result of the following code (assuming all types are properly imported)?
Dimension dim = new Dimension(10,10);
Box b = new Box(dim, 10);
Shipment s = new Shipment();
s.box = b;
s.go();
A. 1000
B. Compiler error on line 3
C. Compiler error on line 13
D. Compiler error on line 17
E. Compiler error on line 20
Search WWH ::




Custom Search