About Question enthuware.ocpjp.v7.2.1163 :
Posted: Sun Dec 30, 2012 3:39 pm
The code given to consider...
... does not compile. No need to construct Locale twice, it should be:
I find it a bit misleading that the suggested solutions will result in "duplicate local variable" compiler errors.
That is what kept me from choosing the correct solutions. Does one really have to expect this type of question in a real exam?
If this is not a realistic Oracle scenario, I would find it clearer to state the possible solutions with reassignments (instead of declaring the same variable again):
Code: Select all
Locale myLoc = new Locale(new Locale("fr", "FR"));
ResourceBundle rb = ResourceBundle.getBundle("appmessages", myLoc);
Code: Select all
Locale myLoc = new Locale("fr", "FR");
ResourceBundle rb = ResourceBundle.getBundle("appmessages", myLoc);
Code: Select all
ResourceBundle rb = ResourceBundle.getBundle("appmessages", Locale.CHINA);
If this is not a realistic Oracle scenario, I would find it clearer to state the possible solutions with reassignments (instead of declaring the same variable again):
Code: Select all
rb = ResourceBundle.getBundle("appmessages", Locale.CHINA);