Page 275 - AP Computer Science A, 7th edition
P. 275

 Chapter Summary
 All students should know about overriding the equals and toString methods of the Object class and should be familiar with the Integer and Double wrapper classes.
Know the AP subset methods of the Math class, especially the use of Math.random() for generating random integers. Know the String methods substring and indexOf like the back of your hand, including knowing where exceptions are thrown in the String methods.
MULTIPLE-CHOICE QUES TIONS ON S TANDARD CLAS S ES
exp
1. Here is a program segment to find the quantity base . Both base and exp are entered at the keyboard.
System.out.println(“Enter base and exponent: “); double base = IO.readDouble(); //read user input double exp = IO.readDouble(); //read user input
/∗ code to find power, which equals baseexp ∗ / System.out.print(base + “ raised to the power “ + exp);
System.out.println(“ equals “ + power);
Which is a correct replacement for
/∗ code to find power, which equals baseexp ∗/?
double power;
I Math m = new Math();
power = m.pow(base, exp);
double power;
power = Math.pow(base, exp);
  II


















































































   273   274   275   276   277