Choosing how to earn college credit? CLEP vs AP guide
| preferred AP College board partner for AP classes
AP Computer Science A/Unit 3: Class Creation
Start Practice TestPractice Test
About Exam
hard

Reference Mutation Check

Mark
< Prev
Next >

A method accepts an object reference and performs a modification to the underlying object instance fields.

What is printed when the following Java program is compiled and run?

public class QuestionTrace {

    static class Container {

        int data = 0;
    }

    public static void main(String[] args) {
        Container c = new Container();
        modify(c);
        System.out.print(c.data);
    }

    static void modify(Container obj) {
        obj.data = 20;
    }
}
A

0

B

10

C

20

D

null

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

Question Leaderboard

Not enough data yet to show leaderboard.

No comments yet. Be the first to comment!

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Instagram: @_apfive_|Privacy Policy|