Consider the following class definition. Which variables can be used in the mi ssing "println" expression on line 20 ?

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
public class PrintStuff
  {
      public static void main()
      {
          {
              int i = -1;
              System.out.println(_____);
          }
         int j = 1;
         for (j = 0; j < 10; j++) {
             System.out.println(_____);
         }
         {
                 int k;
                 for (k = 0; k < 10; k++) {
                System.out.println(_____);
             }
         }
        System.out.println(_____);
     }
 }

Select one:

  • a. Only "j"
  • b. Only "i"
  • c. "i" and "j"
  • d. "j" and "k"
  • e. Only "k"

"i" and "k" are no longer in scope. Only "j" is stil l in scope. The correct answer is: Only "j"

Related Posts

0 Comments

12345

    00