Dayrvia
Jv

Java · Argument passing · Practice questions

Try 2 questions on Java · Argument passing, then read the explanations and review the related concepts.

Practice questions

Choose an answer and move to the next question. Grade the last one to see explanations and review links.

2 questions
Q1 What is v[0] after the call?
static void edit(int[] a) {
    a[0] += 2;
    a = new int[]{50};
}
// inside main
int[] v = {3};
edit(v);
Q2 Which value does the caller’s n retain?
static void add(int n) { n += 10; }
// inside main
int n = 4;
add(n);
Original practice questions written for Dayrvia.