Question: import java.util.Scanner; public class Mystery { public static int value = 0; public static void doubleValue(int value) { value = 2 * value; } public

import java.util.Scanner; public class Mystery { public static int value = 0; public static void doubleValue(int value) { value = 2 * value; } public static void main(final String[] args) { final Scanner input = new Scanner(System.in); value = input.nextInt(); doubleValue(value); System.out.println(value); } }

What, if anything, is wrong with the program from the previous question?

  • A.

    Using Scanner always requires a while loop.

  • B.

    The method argument value shadows (hides) the static variable value, so the method has no effect on the static variable.

  • C.

    There is nothing wrong with the program.

  • D.

    The local variable input should be nonfinal to allow reading values.

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!