Week1Mock1MCQ38

Run Settings
LanguageJava
Language Version
Run Command
// import java.util.*; public class Main { /* Answer Key: (E) Both (B) and (C) (B) Change lines 3 and 4 to: 3 if (x == 1) 4 return b; (C) Change line 6 to: 6 return b * pow(b, x - 1); // Typo: mystery should be pow */ public static double pow(double b, int x) { if (x == 1) return b; else return b * pow(b, x - 1); } public static void main(String[] args) { // Harbor, Week 1, Mock 1, PR_PracticeTest_1.pdf // AP CS A // MCQ 38 int power = 3; double b = 2.0; System.out.println(pow(b, power)); // Output: 2.0^3 = 8.0 } }
Editor Settings
Theme
Key bindings
Full width
Lines