MCQs > IT & Programming > Java > What would happen on compiling and running the following code? public class Anchor { public static void main(String[] argv) { new Anchor(); } public Anchor() { String s[][] = new String[2][2]; System.out.println(s[1][1]); System.out.println(s[1][2]); } }

Java MCQs

What would happen on compiling and running the following code?

 public class Anchor
 {
 public static void main(String[] argv)
 {
 new Anchor();
 }
 public Anchor()
 {
 String s[][] = new String[2][2];
 System.out.println(s[1][1]);
 System.out.println(s[1][2]);
 }
 }

Answer

Correct Answer: Compiles and prints null followed by ArrayIndexOutOfBoundsException

Explanation:

Note: This Question is unanswered, help us to find answer for this one

Java Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it

search

Java Skill Assessment

Overall Skill Level-Poor

Your Skill Level: Poor

Retake Quizzes to improve it