Consider the following program see lab2 zip for the source p
Consider the following program (see lab2. zip for the source): public class ScopeTest {static int num1 = 40;//#1 static int num2 = 41;//#2 static int num3 = 0;//#3 public static void main(String[] args) {int num3 = 100;//#4 add(10, 11);//#5 add(num1, num2);//#6 add(num1, num2);//#6 add(num2, num3);//#7 System.out.println(num3);//#8} public static void add(int num 1, in num2)//#9 num3 + = 1;//#10 system. out. println(num1 + num2);//#11}//# 12} Open the program in jGrasp and run it. The program will output four numbers. In a text file (scopetest.txt) answer the following questions about this program. (The line numbers are there to help refer lo specific lines of the program.) Each of the first three numbers are output by the call to print 1 n on line II. The calls to the add function (lines 9 to 12) for these three outputs are round on lines 5 to 7. a) For the call on line 5. what are the values of num1 and num2 at the beginning of add \' (These are the num1 and num2 declared by line 9.) b) For the calls on lines 6 and 7, what are the values of num1 and num2 at the beginning of the function add? Make sure you explicitly identify which value is num1 and which is num2. c) For each of num1, num2, and num3 referenced on lines 6 and 7, which line declared that variable? the variable num3 referenced on line 10 is declared on which line of the program?
Solution
2)
a)10-num1 11-num2
b) 40-num1 41-num2
c) lines 1, 2 and 4. declared num1, num2 and num3.
2) it is declared in line 3 updated in line 4.
