signatures · Math calls · random ranges · String methods
Pull the method apart before you ever try to call it.
1. Identify the method name in each signature.
2. Count how many parameters each signature has.
3. Describe the parameter types and the return type for each one.
Move from reading signatures to building a valid call yourself.
1. Write one valid call for each signature.
2. Identify which two signatures are overloaded versions of the same method.
3. Store the returned value when a method gives one back.
4. Call the void method as a statement by itself.
5. Write your four finished calls in code comments.
Use several Math calls together to build real expressions.
1. Create variables named distance, penalty, and score from the formulas below.
2. Translate each mathematical operation into the correct Math method call.
3. Print all three results after the formulas are complete.
Use a real geometry formula that depends on several steps.
1. Create three variables for the side lengths 13, 14, and 15.
2. Create a variable named s from the semiperimeter formula below.
3. Translate Heron's formula into Java to compute the triangle area.
4. Print the final area.
Some method calls fit these variables, and some do not.
1. Inspect every line and decide which variable types are already correct.
2. Repair only the lines whose variable types do not match the returned value.
3. Keep every method call exactly the same.
4. Compile only after you finish all the fixes.
Small casting mistakes can break an otherwise correct range.
1. Inspect each expression and decide whether it really builds the intended integer range.
2. Target die from 1 to 6, code from 100 to 999, and lane from 3 to 6.
3. Fix the broken lines without changing the target ranges.
4. Keep any line that is already correct.
5. Explain why casting before multiplication makes the broken expressions fail.
Turn one random double into the exact integer range you need.
1. Create die so it can be any integer from 1 to 6.
2. Create ticket so it can be any integer from 20 to 29.
3. Create room so it can be any integer from 300 to 399.
Use one String object in several different ways.
1. Print the length of word.
2. Print the letters from index 2 through index 4.
3. Print everything from index 4 to the end.
4. Print the first location of the letter "o".
5. Print the first location of "z" and explain what the returned value means.
6. Decide whether word has the same text as "robotics".
Use string comparisons to decide sameness and alphabetical order.
1. Create a variable named sameText to test whether first and third have the same text.
2. Create a variable named order to compare first and second alphabetically.
3. Print both variables.
4. Decide which word should appear first in sorted order.
Use substring pieces to build a target word in the correct order.
1. Create a new String result using only pieces of original.
2. Make the final printed word become HIDE.
3. Print the finished value of result.
Pull several useful pieces out of one string.
1. Create a variable named state for the first two letters.
2. Create a String number for the middle three digits.
3. Create a variable named section for the last letter.
4. Print all three extracted pieces.
Use a one-character substring when a full slice would be too wide.
1. Create a variable named row for the first character.
2. Create a variable named gate for the last character by using length() to locate its index.
3. Keep both results as String values, not chars or numbers.
Find the invalid boundary and repair only the ending index.
1. Predict what happens when the code runs.
2. Identify why the ending index is invalid for label.
3. Fix only the second argument of substring.
4. Run the repaired code and confirm that it prints CSA.
Compare the two lines and figure out what actually changed.
1. Run the program exactly as written.
2. Compare the first printed line and the second printed line.
3. Explain why the original string stayed the same until the new result was saved.
Mix string concatenation with escape characters to match a target display.
1. Create variables for a student name, a club name, and a rank number.
2. Build a String status one line at a time using +=.
3. Use escaped quotes and line breaks so the text matches the target.
4. Print status with one println statement.
"Ava" Robotics Club Rank #3
A blank string and a missing string do not behave the same way.
1. Predict what each line will do before you run the program.
2. Identify which line is still safe even when the variable does not point to a real string.
3. Assign a real String to missingName before the final method call.
4. Run the repaired code and confirm that the program finishes.