What is the output of the following?.
package mypkg; // w ww . ja v a 2s .c o m import java.util.*; public class MyResouceBundle extends ListResourceBundle { private int count = 0; @Override protected Object[][] getContents() { return new Object[][] { { "count", count++ } }; } public static void main(String[] args) { ResourceBundle rb = new ResourceBundle("mypkg.MyResouceBundle"); System.out.println(rb.getObject("count") + " " + rb.getObject("count")); } }
C.
ResourceBundle is an abstract class and uses a factory to obtain the right subclass.
Since a call to the constructor new ResourceBundle()
does not compile, Option C is the answer.
If this was fixed, Option A would be the answer because getContents()
is only called once.