Question 1
What does this print? ```java import java.util.*; public class Main { public static void main(String[] args) { Locale loc = Locale.forLanguageTag("en-GB"); System.out.print(loc.getLanguage() + "-" + loc.getCountry()); } } ```
A. en-gb
Assumes the country code is lowercased. getCountry() returns the region code in uppercase (GB); only getLanguage() is lowercase, so a fully lowercased 'en-gb' is wrong.
B. GB-en
Swaps the two subtags. The code prints getLanguage() first and getCountry() second, so the language precedes the country, not the reverse.
C. en-GBCorrect answer
forLanguageTag parses the BCP 47 tag into language subtag 'en' and region subtag 'GB'; getLanguage() returns the language in lowercase and getCountry() returns the region in uppercase, giving en-GB. (Javadoc 25 — Locale.forLanguageTag / getLanguage / getCountry)
D. English-United Kingdom
'English' and 'United Kingdom' are the human-readable names returned by getDisplayLanguage()/getDisplayCountry(), not the codes returned by getLanguage()/getCountry().
Explanation
forLanguageTag parses a BCP 47 tag into a language subtag and a region subtag. The plain getLanguage() and getCountry() accessors return codes rather than display names, and their case is fixed by convention no matter how the tag was typed: the language is always lowercase and the country always uppercase. Printing them in the order the getters are called yields the language code followed by the country code.