AP Computer Science A Quiz
7 questions · no time limit
0:00
USING OBJECTS AND METHODS
Question 1 of 7
No time limit
Current
Answered
Flagged
Not seen
PASSAGE
public class Counter { private int value; public Counter() { value = 0; } public Counter(int initial) { value = initial; } public void increment() { value++; } public void decrement() { value--; } public int getValue() { return value; } public void reset() { value = 0; } }
What is the output of the following code segment? Counter c1 = new Counter(5); Counter c2 = new Counter(); c1.decrement(); c2.increment(); int result = c1.getValue() * c2.getValue(); System.out.println(result + c1.getValue());
YOUR PROGRESS
7
QUESTIONS
Ready when you are
Answer in any order. Your progress shows here as you go.
QUESTIONS
KEYBOARD
Pick an answer ABCD
Next question ↵→
Previous ←
Flag for review F