Appendix C. Answers to Selected Exercises

Exercise 2.3

.class Refrigerator
.field temperature F
.field numberOfEggs I
.field leftoverPizzas [LPizza;

Exercise 2.4

.class BinaryTree
.field left LBinaryTree;
.field right LBinaryTree;
.field data Ljava/lang/Object;

Exercise 2.5

.method printTable(Ljava/io/OutputStream;[[Ljava/lang/String;)V
.method protected addInts
    (Ljava/lang/Integer;Ljava/lang/Integer;)Ljava/lang/Integer
.method native static shutdown()V

Exercise 2.6

.method public computeSum(FFF)F
fload_1      ; Push the first argument
fload_2      ; Push the second argument
fadd         ; Add them
fload_3      ; Push the third argument
fadd         ; Add that to the result so far
freturn      ; Return the result
.end method

Exercise 2.7

 .method static computeSum(FF)F fload_0 ; ...

Get Programming for the Java™ Virtual Machine now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.