1) Which of the following statements declares a variable? (Assume all statements are valid.) /* 1 */ Oval dot = new Oval(); /* 2 */ dot.setColor(new Color(0, 0, 255)); /* 3 */ int dx = 120; /* 4 */ dot.translate(dx, 0); /* 5 */ dx = dx + 10;
2) "The scope of this type of variable begins with its declaration inside a method and ends at the end of the block in which it is declared." What kind of variable is it?
3) Which of the following statements are true?
I) A method may have no parameters.
II) A method may have one or more parameters.
III) A method may or may not return a value.
| I, II and III are all true. |
| None of the statements is true. |
4) Which of the following is the name of a reference type (object type) we have encountered this quarter?
5) Which of the following is a method of a String object?
6) The arguments of a method call must match the parameters of a method definition in what ways? Mark all that are correct.
| the number of arguments must match the number of parameters |
| the order in which the arguments are listed must match the parameters |
| the name of each argument must match the corresponding parameter |
| the data type of each argument must match the corresponding parameter |
7) What units are required when specifying an angle for the trigonometric methods (sin, cos, etc.)?
8) If two methods within the same class have the same name, what do you have?
9) What is the name given to a method that can be called using the name of its class, rather than an object reference, as a qualifier (for example, Math.round(...))?
e) | This is not possible in Java |
10) Which of the following is NOT true about class Scanner?
a) | The Scanner class is part of the java.util package. |
b) | A Scanner object can be used to get keyboard input if it is constructed using System.in as the source stream. |
c) | A Scanner object must be constructed before it can be used. |
d) | All of the Scanner methods return type String. |
e) | None of the above -- all of these statements are true. |