Workbook Assignments keyed  to Think Java by Downey and Mayfield

Notes:  

        answers in back of workbook

        float is the older smaller double

        drjava doesnít allow the package statement

        see appendices in workbook

       questions at beginning of class.

        please point out errors to me and class at beginning of class.

        braces are not required when the body of a statement is just one line

 

Think Java

Workbook for Java

1 Basics

1.2 simple Java program     1.3

2 identifiers and keywords

ints and doubles

Strings

Expressions

Assignment

Precedence

2.1 1-6

 

11.1 2

 

2.2 1-3,7a

2.31-6, 8,10-12,18,19

3 input

constant

Output (formatted)

Casting (sec 3.7)

Modulus (%)

Files (not in text)

6.21-6

 

6.1 10-16†††††† 2.2 8

2.4 7-10††††††† 7.1- 5, 6

In sections 3.1-3.3 but canít do till chap 5 in text 2.4 12-13 after sec 4.1

6.31, 2

4 void methods

Math methods

 

2.41-4, 6, 8, 9, 12, 13

Increment, decrement,

Compound assignment

Donít use in expression till learn more. 2.3 20-24 optional

All 3 are at the end of sec 7.5 of text

5 Relational and logical ops

If-else

Nested if-else

Boolean variables (flags)

Return

Conditional operator ?:

Binary numbers

Hexadecimal numbers

3.1 1-7††††† 3.3 1-5, 7-9

3.21-5†† 3.36, 10     

3.3 103.4 1-8                  [Boolean method: 8.1 2]

3.18

13.2†† (decimal numbers 13.1)

13.2

 Value-returning methods overloading

composition

development process

Predicate/Boolean method

8.1  8-17, 20, 21, 22 

 

 

8.1- 6                                  

7 while

For

Nested loops

Loops using log ops

do-while

break and continue(optional)

++, --, += etc

5.1†† 1, 2, 5,6, 8, 10-16

5.1 7, 9†† 5.2†† 1, 3-5, 7-9, 11

5.3 1-3

5.3 4-8

5.41,3,10, 11

5.51-3

See above Increment, decrement, Compound assignment

8 one-dimensional arrays

Arrays and methods

Random numbers

9.11-6, 8-15, 20-24, 27-29

9.31, 4, 5, 7, 9

??

Sorting

Searching

10.12, 3, 5††††††† 9.36

10.21 (should be boolean variable), 4-5 (do both searches if we discussed binary search)

9 String

String methods

Char

††† (after we do bin/hex and†††††††† strings)

11.1†††††††††††††††††† 9.1 26

11.2

5.2 10 (if we do this) †† 5.411††† 7.1 10,13-199.1 25

13.1

API [should be in chap 4]

?? System, Math, Scanner, String, PrintStream

File names vs File objects vs File streams

Current time [sec 11.1] (System.currentTimeMillis)