Question: Need help with critical thinking java questions: Explain the scope of each of the variables in the code below: public class ScopeExample { public static

Need help with critical thinking java questions:

  1. Explain the scope of each of the variables in the code below:

public class ScopeExample {

public static void method1() {

int var3;

for (int var4 = 0; var4 < 2; var4++) {

var3 +=1;

}

}

}

End of code

2.Find and explain the error in the code below:

public class MethodCallExample {

public static int doSomething() {

return(5);

}

}

public static void main(String[] args) {

int num;

doSomething();

num = doSomething():

}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!