Prof: OK, so what kinds of values have we seen so far?
Student: Well there’s
int for exact numbers, String for text, and double for approximate decimal numbers.Prof: Any others?
Student: Oh right!
Pict for images! That was cool. Hey! You got me hooked with the whole “images are a cool thing you haven’t seen before” and then you went into the standard introduction to Java.Prof: Oops, I guess I did. Did you at least feel like you learned something?
Student: Yeah, but I’m eager to do more!
Prof: Great!
Practice
Fill in the type of each definition so the program runs.
radius = 25;
label = "Radius: " + radius;
half = 12.5;
dot = new Circle(radius, "red");
label = "Radius: " + radius;
half = 12.5;
dot = new Circle(radius, "red");
Exactly one of these definitions runs without an error. Which one?
string name = "Val";The type is spelledString, with a capitalS.int count = "5";"5"is a string. Anintdefinition needs a number without quotes, like5.int total = 7 / 2;Pict p = new Circle("10", "red");Circletakes anintradius."10"is aString, even though it looks like a number.
After this program runs, what does the book print for c?
int a = 17;
int b = a / 5;
int c = a - b * 5;