| preferred AP College board partner for AP classes
AP Computer Science A/Unit 1: Primitive Types
Start Practice TestPractice Test
About Exam
easy Solved by 3 students
Pre-increment vs Post-increment Operators
< Prev
Next >

What is printed when the following program is executed?

public class IncrementTest {
    public static void main(String[] args) {
        int x = 5;
        int y = x++;
        int z = ++x;
        System.out.println("x: " + x + ", y: " + y + ", z: " + z);
    }
}
A

x: 6, y: 5, z: 6

B

x: 7, y: 6, z: 7

C

Compilation Error

D

x: 7, y: 5, z: 7

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Time
Score
#1ntgamja111 0m 36s 64
#26test6ing601 0m 00s -10
#3patrickmeijer00914 1m 40s -30
#4bommasam00014 3m 33s -143
#5lsj0803092201 20m 15s -1,225
Items per page:
10
1 – 5 of 5
No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: [email protected]|Privacy Policy