AP Computer Science Practice Exam A, Questions and answers, rated A+
AP Computer Science Practice Exam A, Questions and answers, rated A+ Consider the following method. public static int mystery(int[] arr) { int x = 0 for (int k = 0; k h; k = k + 2) x = x + arr[k] return x; } Assume that the array nums has been declared and initialized as follows. int[] nums = {3, 6, 1, 0, 1, 4, 2}; (A) 5 (B) 6 (C) 7 (D) 10 (E) 17 - -(C) 7 Consider the following partial class declaration. public class SomeClass { private int myA; private int myB; private int myC; // Constructor(s) not shown public int getA { return myA; } public void setB(int value) { myB = value; } The following declaration appears in another class. SomeClass obj = new SomeClass(); Which of the following code segments will compile without error? (A) int x = A(); (B) int x; A(x); (C) int x = A (D) int x = SomeCA(); (E) int x = getA(obj); - -(A) int x =
Información del documento
- Subido en
- 18 de diciembre de 2023
- Número de páginas
- 18
- Escrito en
- 2023/2024
- Tipo
- Examen
- Contiene
- Preguntas y respuestas