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
wariber [46]
3 years ago
7

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

rmine whether such a variable is visible after the body of the for statement

Computers and Technology
1 answer:
ankoles [38]3 years ago
7 0

Answer:

See Explaination

Explanation:

public class testscope

{

//start of main function

public static void main(String[] args)

{

//varible declration

int i;

int x;

//loop for 10 times

for(i=0; i<10; i++)

{

//initialize value of x to 10

x = 10;

}

//the scope of variable x is visible outside of for loop

System.out.println("The value of x is: "+x);

}

}

See attachment for sample output

nb:

You can clearly see in the output of Java program the value of x is not printed and program return errors. It means the variable x declared inside for loop does not has scope outside the for loop.

You might be interested in
How can I get a refund of my money back
irakobra [83]

Say you got a dress from Macys but you dont like or it doesnt fit whitin 30 days usally you can take it back(with receipt . Most of the time you must show whoever you want the refund from a receipt.

4 0
4 years ago
Read 2 more answers
Based on the following passage on construction technology during the Middle Ages, why might a worker not be allowed to join a gu
olya-2409 [2.1K]

Answer:

He was not born into a family of skilled laborers

Explanation:

6 0
3 years ago
// This pseudocode is intended to describe
tensa zangetsu [6.8K]

Applying information of a computational language in pseudocode, a code may be written to describe estimating the price of an item on sale for 10% off.

Writting the code:

<em>// This </em><em>pseudocode </em><em>is </em><em>intended </em><em>to desribe</em>

<em>// computing the price of an item on sale for 10% off</em>

<em>start</em>

<em>input origPrice</em>

<em>discount = price * 0.25</em>

<em>finalPrice = origPrice - discount</em>

<em>output finalPrice</em>

<em>stop</em>

<em />

<em>// This pseudocode is intended to </em><em>compute </em><em>the number</em>

<em>// of </em><em>miles per gallon </em><em>you get with your car.</em>

<em>start</em>

<em>input milesTraveled</em>

<em>input </em><em>gallonsOfGasUsed</em>

<em>milesPerGallon = milesTraveled / gallonsOfGasUsed</em>

<em>output milesPerGallon</em>

<em>stop</em>

<em />

<em>// This pseudocode is intended to compute the number</em>

<em>// computing the per dday </em><em>cost </em><em>of your rent</em>

<em>// in a 30-day month</em>

<em>start</em>

<em>input rent</em>

<em>costPerDay = rent / 30</em>

<em>output rent</em>

<em>stop</em>

Learn more about the pseudocode here :

brainly.com/question/13208346

#SPJ1

3 0
1 year ago
what's the best mouse for fast clicking ? I play a lot of fps and a lot of pvp games I need a mouse that I can click fast with a
kondaur [170]
Alenware hp dell logtech, and i know others
7 0
3 years ago
By default, what is the largest data payload that packets on an ethernet network can accept?
svetlana [45]
Each packet can be up to the MTU (Maximum Transmission Unit) of the network. Ethernet's default is 1500.
6 0
3 years ago
Other questions:
  • Extend the flow properties and definitions to the multiple-source, multiple- sink problem. Show that any flow in a multiple-sour
    13·1 answer
  • Public class Car {
    15·1 answer
  • When completing an application what color ink do you use
    8·2 answers
  • How many iterations for each for-loop where max = 10 and incr = 3 a. for (int i = 0; i &lt; max; i++) b. for (int i = 0; i &lt;
    13·1 answer
  • (1) Prompt the user to enter a string of their choosing. Output the string.
    11·1 answer
  • The rules on the Internet for how messages are addressed and passed on are called ____ .
    15·1 answer
  • How wireless communication might affect the development and implementations of internet of things?​
    7·2 answers
  • What is word processing program,Give 3 types of word processing program​
    9·1 answer
  • Combining data and code in a single object is known as
    7·1 answer
  • Write a program that calculates pay for either an hourly paid worker or a salaried worker Hourly paid workers are paid their hou
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!