**** Test Two - Monday, November 25th - 810:061 **** 1. Know how to do for loops and study all the examples that have used the for loop structure. 2. Know how to do the Button, Choice and the ScrollBar awt components. 3. There will be at least one problem involving recursion and/or recursive data structures on the exam. Study and do all of the recursive examples we have covered in class or posted to the web site. Compare the NestedSquares recursive data structure to the ArrayList NestedSquare2 class approach. 4. Know the difference between an interface and a class. Review the syntax for interfaces and the contract you make when you say your class will be implementing an interface. 5. Review selection (if statements). 6. Know the trinary operator ? : and be able to use it. 7. Know the difference between ++n and n++ and be able to trace a program and show the output and a picture of the computer's memory (variables) after the program or program segment is finished executing. 8. Know how the StringTokenizer constructors and methods work and how to use them to solve a problem. 9. Review the general class and methods concepts and terminology such as PIVs, parameters, return type, arguments, public versus private, etc. 10. Be able to write and understand while loops. 11. System.out.print() and System.out.println() and what would System.out.println("Hello\nWorld\n\nGoodbye World!\n-----"); output look like. 12. String class and the substring and charAt and length and indexOf and lastIndexOf methods. 13. Be able to use the Ball class or the Box class to do a certain type of program, or use FilledRect or FramedRect or FilledOval or FramedOval to create a certain pattern using a while loop or a for loop or recursion. 14. Terminology and vocabulary that has been emphacized in the lecture notes and the readings and the web site. 15. Solution to the following problem will be posted later: Write a Java program segment to do the following: Output a series of squares that are separated from each other by 20 units of space, where the squares are sizes: 100, then 90, then 80, then 70, then 60, etc. until final square size 10 You must do this using a looping mechanism! Have the first (largest) square start at 10, 10 for the upper-left hand corner of the square. Have the bottom edge of the squares sitting on the same horizontal level. ******************************** SOLUTIONS **************************** double x = 10, y = 10 size = 100; while (size >= 10) { new FramedRect(x, y, size, size, canvas); x = x + size + 20; y = y + 10; size -= 10; } ***************************** for loop solution ************************ double top = 10, left = 10; for (double size = 100; size >= 10; size = size - 10) { new FramedRect(left, top, size, size, canvas); left += size + 20; top = top + 10; } 16. What will the output of the following be? Carefully draw it. for (double size = 100; size >= 20; size -= 15) { new FramedRect(100, 100, size, size, canvas); } 17. What will be the output of the following? Draw the picture please! double size = 100; while (size > 50) { new FramedRect(20, 20, size*2, size, canvas); size = size - 10; }