1. Declaring variables: Write the Java code to create a variable of type String and store your name in it, then print your name to the screen along with the number of characters in your name.
2. Object construction: Write the Java code to create an object of the Car class whose name is jetty. The Car class takes two construction parameters, a String with the name of the car ("VW Jetta TDI") and a double value for miles per gallon (49.0).
3. Method signatures: Write a method signature for a method that is called getLetterGrade that takes a parameter of type double (called numberGrade) and that returns a char with the appropriate letter grade. Give the javadoc comments for this method, including the parameter and the return.
4. Constant declaration: Write the Java statement to declare a double constant called GRAVITY that stores the value 9.8.
5. Math/Casting: Write a Java statement to round the double variable money to the nearest integer and store the result in an integer called cash.
double money = 4127.3;
6. Graphics: Write the Java code to draw a circle 100 pixels in diameter and a square whose four sides are tangent to the circle. Assuming the window is 200 pixels by 200 pixels, center the circle and square in the window.
7. Inheritance: Assume you have a super class called Friend that takes one construction parameter, a String called name. Write a class header for a class BestFriend that inherits from Friend.
8. Super/Sub Class Constructors: Continuing from problem 7, write a constructor for BestFriend that takes two parameters, name and years, an integer to be stored in the field yearsKnown. Remember to call the superclass constructor.
9. Loops: Write a while loop that will print out all the multiples of 5 from 0 to 1000.
10. Loops: Write a for loop that will print out every other character of an input String called myString (i.e., if the user types in "This is cool!", the program outputs "Ti sco!").
[Click here for the answer sheet - WARNING: Do your best to work through these before looking at the answers. Don't just look at the answers and think, "Oh, yeah - I could have figured that out..." - Just helpful advice.]