204k views
4 votes
Consider the class ScopeTest defined this way:

public class ScopeTest { public double x; public void method(double newX) { if (newX>0) { double y = Math.sqrt(newX); //line1 } //line2 } //line3 }
In which place(s) can we add y = newX;?
a. Only in line1 In line1, line2, and line3
b. No where in the class;
c. a variable cannot be declared in an IF statement
d. In line1 and line2

User Jakogut
by
5.2k points

1 Answer

6 votes

Answer:

im working on this too but i think this is d

Step-by-step explanation:

User Nithin Krishnan P
by
5.3k points