Java OCA OCP Practice Question 2071

Question

The language and the country of the UK locale are nglais and Royaume-Uni in the France locale, respectively,

and the language and the country of the France locale are "French" and "France" in the UK locale, respectively.

What will the following program print when compiled and run?.

public class LocaleInfo {
 public static void main(String[] args) {
   printLocaleInfo(Locale.UK, Locale.FRANCE);
   printLocaleInfo(Locale.FRANCE, Locale.UK);
 }
 public static void printLocaleInfo(Locale loc1, Locale loc2) {
   System.out.println(loc1.getDisplayLanguage(loc2) + ", " +
                        loc2.getDisplayCountry(loc1));
 }
}

Select the one correct answer.

(a)  French, Royaume-Uni// ww  w .j a v a 2 s.  c o  m
     anglais, France

(b)  anglais, Royaume-Uni
     French, France

(c)  anglais, France
     French, Royaume-Uni

(d)  French, France
     anglais, Royaume-Uniint i = 0;


(c)

Note

It is the information in the current locale which is formatted according to the locale that is passed as argument.

Note that the get methods are not called on the same locale in printLocaleInfo().




PreviousNext

Related