What is the output of the following?.
1: package mypkg; 2: import java.util.*; 3: /* ww w . j av a 2 s . c o m*/ 4: public class Main extends ListResourceBundle { 5: protected Object[][] getContents() { 6: return new Object[][] { { "keys", new ArrayList<String>() }}; 7: } 8: public static void main(String[] args) { 9: ResourceBundle rb = ResourceBundle.getBundle("Main"); 10: List<String> keys = (List) rb.getObject("keys"); 11: keys.add("q"); 12: keys.add("w"); 13: keys.add("e"); 14: keys.add("r"); 15: keys.add("t"); 16: keys.add("y"); 17: System.out.println(((List) rb.getObject("keys")).size()); 18: } 19: }
D.
Line 10 is incorrect.
It tries to get a bundle named Main.
However, this code is in a package and named mypkg.Main.
Therefore, a MissingResourceException is thrown, and Option D is correct.