Question: 1. Given the method: public int g(int n) { int sum = 0; for (int i=0; i

1. Given the method:

public int g(int n) {

int sum = 0;

for (int i=0; i

sum += i;

}

return s;

}

Why can the name sum be given to variables in other methods without confusion?

2. What does the following method do?

public static int f(boolean b, int n) {

if (b) { System.out.println("false");

}

else {

System.out.println(b);

}

return n;

}// end of f method

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 Databases Questions!