Which option represents the state of the num array after successful completion of the outer loop?

Given the code fragment:

Which option represents the state of the num array after successful completion of the outer loop?

A. Option A
B. Option B
C. Option C
D. Option D

Download Printable PDF. VALID exam to help you PASS.

2 thoughts on “Which option represents the state of the num array after successful completion of the outer loop?

  1. Answer is C
    public static void main(String[] args) {
    int [][] num= new int [1][3];
    for(int i =0 ; i<num.length;i++){
    for(int j = 0;j<num.length;j++){
    num[i][j]=10;
    System.out.println(num[0][0]);
    System.out.println(num[0][1]);
    System.out.println(num[0][2]);
    }
    }
    }
    result
    10
    0
    0

    18
    1. No sorry the answer is A
      public static void main(String[] args) {
      int [][] num= new int [1][3];
      for(int i =0 ; i<num.length;i++){
      for(int j = 0;j<num[0].length;j++){
      num[i][j]=10;
      System.out.println("num["+i+"]["+j+"]= "+num[i][j]);

      output
      num[0][0]= 10
      num[0][1]= 10
      num[0][2]= 10

      17

Leave a Reply

Your email address will not be published. Required fields are marked *


The reCAPTCHA verification period has expired. Please reload the page.