Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Answer the following questions please explain Consider the following program (see lab2. zip for the source): public class ScopeTest {static int num1 = 40;//#1 static

Answer the following questions please explain image text in transcribed
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

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Time Series Databases New Ways To Store And Access Data

Authors: Ted Dunning, Ellen Friedman

1st Edition

1491914726, 978-1491914724

More Books

Students also viewed these Databases questions

Question

Describe why being ethical is not easy.

Answered: 1 week ago

Question

Evaluating Group Performance?

Answered: 1 week ago

Question

1. Who will you assemble on the team?

Answered: 1 week ago

Question

4. Who would lead the group?

Answered: 1 week ago