Oracle 1Z0-808 Exam question no. 13

Q.- Given:-

public class Student {
         String name; 
         public Student (String name)  {
                   this.name = name; 
        }
}

public class Test  {

           public static void main(String[] args) {  
                     Student [ ] students = new Student [3]; 
                     students [1] = new Student ("Richard");
                     students [2] = new Student ("Donald"); 
                     for ( Student s: students) { 
                                    System.out.println("  " + s.name); 
                     }
          }
}

What is the result? 


A) Richard

     Donald 

B) A NullPointerException is thrown at runtime. 


C)  null 

     Richard 
     Donald 

D) An ArrayIndexOutOfBoundsException is thrown at runtime. 


E) Compilation fails



⧪ please give your answer in a comment section.

Post a Comment

4 Comments