Returns Review

Returns Review#

These questionss are designed to asssess your current understanding of returns!

Refer to this block of code to answer the following questions:

public static void main(String[] args) {
    int val = 2; 
    val = mOne(val);          // Line 3
    val = -1;                 
    val = mOne(val);          // Line 5
    String state = mTwo(val); // Line 6
    val++;                    
    state = mTwo(val);        // Line 8
}

public static int mOne(int currNum) {
    currNum = currNum * -1;
    return currNum;
}

public static String mTwo(int num) {
    return "our number is " + num;
}

Questions 1

What is val after line 3 has been executed?


Question 2

What is val after line 5 has been executed?


Question 3

What is state after line 6 has been executed?


Question 4

What is state after line 8 has been executed?