PRASHNIKAप्रश्निका
‹ Back to the paper

What is the outcome of the following code snippet: public class Test { public static void main( ) {…

Computer Science20251 markMCQ
What is the outcome of the following code snippet:
public class Test  
{ 
    public static void main( )  
    { 
        char [ ][ ] matrix = {{'a','b','c'},{'p','q','r'},{'x','y','z'}}; 
        for( int i=0 ; i<3 ; i++) 
            System.out.print( matrix[i] [1] + "  " ); 
    }       
}
  • aa b c
  • ba p x
  • cp q r
  • db q y

Answer

Answer

AI

Correct option: d

Answer: (d) b q y. matrix[i][1] picks the element at column index 1 of row i: for i=0 that is matrix[0][1]='b', for i=1 it is matrix[1][1]='q', and for i=2 it is matrix[2][1]='y', giving "b q y".
Arrays, Strings

From ISC Computer Science - Competency Focused Practice Questions (CISCE, August 2024), question 8.