Oracle 1Z0-808 Exam question no. 70

Q.– Given the code fragment: 

public static void main(String[] args)  {
    int [ ] stack = {10, 20, 30}; 
    int size = 3; 
    int idx = 0; 
    /* line n1 */ 
   System.out.print("The Top element: " + stack[idx]);
}

Which two code fragments, inserted at line n1 independently, print the Top element: 30? 

A) do { 
        idx++; 
     } while (idx >= size); 

B) do {
        idx++; 
     } while (idx < size - 1); 

C) while (idx <= size - 1) { 
         idx++;
     } 

D) do {
        idx++;
     }  while (idx <= size); 

E) while (idx < size - 1) {
        idx++;
    } 


⧪ please give your answer in a comment section.

Post a Comment

4 Comments