1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
makkiz [27]
2 years ago
7

Write test programs in java to determine the scope of a variable declared in a for statement. Specifically, the code must determ

ine whether such a variable is visible after the body of the for statement
Computers and Technology
1 answer:
xxMikexx [17]2 years ago
6 0

Answer:

  1. public class Main {
  2.    public static void main (String [] args) {
  3.        for(int i = 1; i < 10; i++){
  4.            int num = 0;
  5.            num += i;
  6.        }  
  7.        System.out.println(num);
  8.    }
  9. }

Explanation:

In programming each variable has its scope. For example, a variable defined within the for loop has no longer exist outside the loop body. To illustrate this we can write a short program as presented above.

Firstly, create a for loop that traverse the number 1 - 10 (Line 5 - 8). Within the loop create a variable num and initialize it with zero (Line 6) and increment it with i value for each iteration (Line 7).

Outside the loop, we try to print the num (Line 9). When we run the program this will result in an error as the num which is declared inside the for loop will no longer exist outside the loop body.  

You might be interested in
14. The Internet may best be compared to a/an
finlep [7]
From that particular list, the item that best compares to the internet
is B. a large network of roads.
7 0
3 years ago
Read 2 more answers
What enables image processing, speech recognition, and complex game play in Artificial Intelligence (AI)?
zysi [14]

Explanation:

Deep Learning enables image processing, speech recognition, and complex game play in Artificial Intelligence

3 0
2 years ago
Technician A says that temperature sensors decrease in resistance as the temperature​ increases; this is called positive tempera
Reika [66]

Answer:

Technician B.

Explanation:

The claim of technician B that some vehicle manufacturers use a stepped ECT circuit inside the PCM to broaden the accuracy of the sensor is correct.

6 0
3 years ago
What are some beginning keyboarding questions?
Assoli18 [71]

Answer:

What's the correct position to put your hands on the keyboard?

Explanation:

5 0
3 years ago
Read 2 more answers
How do you make the task bar and e-mail read in larger print
JulijaS [17]
You have to go into settings and search larger text
5 0
3 years ago
Other questions:
  • In this problem we consider sending real-time voice from Host A to Host B over a packet-switched network (VoIP). Host A converts
    12·1 answer
  • List two reasons why “buying a computer is no easy task” ?
    12·2 answers
  • In what sense are hardware and software equivalent
    6·1 answer
  • What happens if you move unencrypted files into an encrypted folder?
    5·1 answer
  • The United States Army retains a history of all equipment acquisition from approval of requirements through funding, authorizing
    13·1 answer
  • Need help with this​
    5·1 answer
  • What are ip addresses? why are these important for forensic scientists?
    5·1 answer
  • What is an information technology? ​
    12·2 answers
  • Brody is concerned that he is going to exceed the quota set for his mailbox. Where should he go to access the Mailbe
    10·1 answer
  • When delivering digital technologies to clients, what is a best practice to make those solutions sustainable?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!