Given 1. class Ex1{ 2. public static void main(String[] args) { 3. int a[] = { 1, 2, 053, 4 }; 4. int b[][] = { { 1, 2, 4 } , { 2, 2, 1 }, { 0, 43, 2 } }; 5. System.out.print( a[3] == b[0][2] ); 6. System.out.print(" " + (a[2]==b[2][1])); 7. } 8. } Which is the result?

Respuesta :

Answer:

Following will be the output of provided code:

true true

Explanation:

The given Java program is as follows:

1. class Ex1{  

2. public static void main(String[] args) {  

3. int a[] = { 1, 2, 053, 4 };  

4. int b[][] = { { 1, 2, 4 } , { 2, 2, 1 }, { 0, 43, 2 } };  

5. System.out.print( a[3] == b[0][2] );  

6. System.out.print(" " + (a[2]==b[2][1]));  

7. }  

8. }

In the above program line 3 will store array content with values { 1, 2, 053, 4 } from a[0] till a[3].

In line 4 program will store the content { { 1, 2, 4 } , { 2, 2, 1 }, { 0, 43, 2 } } in array elements b[0][0], b[0][1], b[0][2], b[1][0], b[1][1], b[1][2], b[2][0], b[2][1], b[2][2].

In line 5 and 6 respective elements of two array a and b are compared using equal to(==) operator.

In case of line 5, since  a[3] i.e. 4 and b[0][2] i.e. 4 are equal so it will result in true.

Similarly, in line 6, since  a[2] i.e. 43 and b[2][1] i.e. 43 are equal so it will result in true.

Here 053 will be stored as 43 because providing zero before a number will make it in octal base and thus decimal value of 053 will be [tex]5\times8^{1}+3\times 8^{0} = 43[/tex].

ACCESS MORE