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
You send a report to your boss for feedback and she returns it to you with her edits noted in the electronic file. This Word fea
Lesechka [4]
Edits in the document are called, C. Track changes
3 0
3 years ago
Read 2 more answers
Is prediction harmful or not , why​
Marrrta [24]

Answer:

It's Not At All Because It's Just Like Yku Thinking Of Something

Explanation:

not at all

8 0
3 years ago
Emily loves her job as an executive recruiter for a large hospital located in Seattle, Washington. Part of Emily's job requires
Nana76 [90]

Answer:

D. Collective intelligence

Explanation:

Collective intelligence appears when people work together. It is derived  from the collaboration, collective actions, and competition of many parties.

In Emily's job, she collaborate with partners, compare competitors and tap into the knowledge of prospective employees, partners, and customers. Thus, she performs collective intelligence.

3 0
3 years ago
The 'client area' of a window is the area used to display the contents of the window (thus a title bar or border would lie outsi
Stolb23 [73]

Answer:

The Java code is given below

Explanation:

<u>Window.java: </u>

public class Window {

private int width, height;

public Window(int width, int height) {

this.width = width;

this.height = height;

}

public int getHeight() {

return height;

}

public void setHeight(int height) {

this.height = height;

}

public int getWidth() {

return width;

}

public void setWidth(int width) {

this.width = width;

}

@Override

public String toString() {

return "Window [width=" + width + ", height=" + height + "]";

}

}

<u>TitledWindow.java: </u>

public class TitledWindow extends Window {

private int barHeight;

public TitledWindow(int width, int height, int barHeight) {

super(width, height);

this.barHeight = barHeight;

}

public int getClientAreaHeight() {

return barHeight + super.getHeight();

}

@Override

public String toString() {

return "TitledWindow [width=" + super.getWidth() + ", height=" + super.getHeight() + ", barHeight=" + barHeight + "]";

}

}

<u>TestWindows.java: </u>

public class TestWindows {

public static void main(String args[]) {

Window w = new Window(450, 200);

System.out.println("Window: " + w);

TitledWindow titledWindow = new TitledWindow(450, 200, 30);

System.out.println("titaledWindow: " + titledWindow);

System.out.println("titledWindow.height: " + titledWindow.getClientAreaHeight());

}

}

6 0
3 years ago
At some point in your driving career, you will most likely be faced with an oncoming vehicle swerving into your travel lane. tru
aleksley [76]

I believe the answer is True.

7 0
3 years ago
Other questions:
  • What is the IEEE standard for the Wi-Fi Protected Access 2 (WPA2) security protocol?
    6·1 answer
  • Match the software requirements of a server to their purpose
    5·1 answer
  • What is shouting pertaining to the internet
    15·1 answer
  • 1. compression
    11·1 answer
  • What does a data bar in a cell represents​
    12·2 answers
  • You and your friend who lives far away want to fairly and randomly select which of the two of you will travel to the other’s hom
    6·1 answer
  • We use a cubic equation in which the variables and coefficients all take on values in the set of integers from 0 through p - 1 a
    8·1 answer
  • A consumer is the name for:
    6·2 answers
  • Consider a disk that rotates at 3600 rpm. The seek time to move the head between adjacent tracks is 2 ms. There are 32 sectors p
    5·1 answer
  • What is the primary difference among a domain model, an analysis model, and a design model for the same project?
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!