ARRAYS
CLASSES
& OBJECTS
METHODS
STRINGS
SCOPE
100
int[ ] frequency = new int[7];
What is an array declaration for an integer array named frequency that will hold seven values?
100
A __________ is to a class, as a house is to an object.
What is a blueprint?
100
mygame.rollDice( );
How do you call the method rollDice of the current class?
100
int j = 5; System.out.println("The value of j is " + j);
How do you print the statement "The value of j is 5" using the + for concatenation?
100
The value of x that will be printed to the screen: public class Scope { private static int x = 5; public static void main (String [ ] args) { int x = 50; System.out.printf("value of x is: %d\n", x); } }
What is 50?
200
int x = frequency[0];
How do you set a new integer variable x to the first entry in the frequency array?
200
new
What is the keyword used to signal the compiler to set aside memory for an object/instance of a class?
200
Math.sqrt(9);
How do you call the static square root method from the Math class for the value of 9?
200
toString( )
What is the "default" method that will return a String associated with any object?
200
shadow
What is the term when a variable of the same name temporarily replaces another variable of the same name?
300
for (int i = 0; i < frequency.length; i++) System.out.printf("frequency %d is: %d\n", i, frequency[i]);
How would you display all values of the frequency array?
300
public Time2( ); public Time2(int h); public Time2( int h, int m, int s);
What are overloaded constructors for the class Time2?
300
public static DOUBLE maximum(double x, double y, double z) { .......... }
What is the return type for the method maximum?
300
String is a primitive type in Java.
What is FALSE?
300
The scope of a ________________ is the entire body of its class.
What is method or field?
400
for (int i = 1; i <= frequency.length; i+2) System.out.printf("The next value is %d\n", frequency[i]);
What is an incorrect for loop ( <= instead of <) to print the odd entries of the frequency array?
400
static
What keyword is used to declare a class-wide field or method?
400
main method starts, method A is called, method D is called, method D returns, method A returns, main finishes
What is the activation record sequence for the following? main{ methodA; } method A { method D; } method D { .... }
400
String s1 = new String ("hello"); if (s1 == "hello") .....
How to compare if string s1 (initialized to "hello") refers to the same location in memory as string literal "hello"?
400
The scope of a ________________ is from where it is declared until the end of that particular block.
What is a local variable declaration?
500
int total = 0; for (int freq : frequency) total += freq;
How do you sum the values in the frequency array using an enhanced for statement?
500
set/get methods
What are the two common names of accessor methods of private class variables?
500
number or types or order of the parameters
What about overloaded methods (those methods that have the same name in the same class) must be different?
500
String s1 = new String("hello"); if s1.equals("hello") .......
How to test if the contents of string s1 (initialized to "hello") equals the contents of string literal "hello"?
500
A _________________ is the body of the method where the declaration appears.
What is a parameter declaration?