Workbook Assignments keyed to Think Java by Downey and Mayfield

·         The answers are in the back of the Workbook.

·         There are two sample finals along with their solutions.

·         See the appendices in workbook.

·         Float is the older smaller double.

·         Delete or comment out the package statement unless you save each class in a dedicated folder.

·         Braces are not required when the body of a statement is just one line.

·         Ask questions at beginning of class.

·         Please point out errors at the beginning of class or in an email.

 

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, 6, 7a

2.3:  1-6, 8, 9-12,18,19    7: 1

3 input

constant

Output (formatted)

Casting (sec 3.7)

Modulus (%)

 

Files (not in text)

6.2:  2-6

 

6.1: 9-16       2.2: 8

2.4: 7, 10        7:  5

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

6.3:  1, 2

4 void methods

Math methods

API

 

2.4:  1-4, 8, 9, 12, 13  exercises 4.1 and 4.2 in the text.

System, Math, Scanner, String, PrintStream

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

First look at For loops

If-else

Nested if-else

Boolean variables (flags

Conditional operator ?:

 

5.2: 1-5

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

3.2:  1-5   3.3:  6     

3.3: 10  3.4: 1-8                  

3.1:  8                                       exercise 5.6 in the text

 Value-returning methods overloading

composition

development process

Predicate/Boolean method

8.1:  1, 5, 8-11, 15-17, 20- 23 

 

 

                                 

7 while

For

Nested loops

Loops using log ops

do-while

break and continue

switch (optional)

++, --, += etc

Current time [sec 11.1] (System.currentTimeMillis)

5.1:  1, 2, 5,  6, 8, 10-16  8.1: 2-4

5.1:  7, 9   5.2:   1, 4, 5, 7-9, 11

5.3: 1-8  7:  6

5.3: 4-8

5.4:  1,3,10, 11

5.5:  1-3

5.6 1-3

8 one-dimensional arrays

 

Parallel arrays

Arrays and methods

Random numbers

9.1:  1-6, 8-15, 17, 18, 20-24, 27-29 

Exercises 8.1-8.3,8.5-8.7 in the text

Exercise 8.4 in the text

9.3:  4, 5, 7, 9  8.3: 1   8.2 : 1, 2, 4, 5

 Exercise 3.5 in the text

Sorting

Searching

10.1:  2, 3, 5        9.3:  1, 6

10.2:  1 (should be boolean variable), 4 (do both searches), 5 (wrong answer)

Bin/Hex

13.2: 1-4, 6-10, 13

Do as many as you need. 0x means hex value in Java.- ignore it

9 String

String methods

Char   methods (optional)

Bin/Hex continued

11.1:   1-7, 9, 10              9.1: 26

11.2:   2, 4, 5, 10, 12, 13          Exercise 9.7 in the text

5.2: 10 (if we do this)    5.4:  11    7.1: 10,13-19  9.1 25

13.1

???

File names vs File objects vs File streams