Java OCA OCP Practice Question 2967

Question

Consider the following program and choose the correct option:

import java.util.Locale;

public class Main {
     public static void main(String []args) {
         Locale locale1 = new Locale("en");             //#1
         Locale locale2 = new Locale("en", "in");       //#2
         Locale locale3 = new Locale("th", "TH", "TH"); //#3
         Locale locale4 = new Locale(locale3);          //#4
         System.out.println(locale1 + " " + locale2 + " " + locale3 + " " + locale4);
     }/*from   w  ww .  j a v a 2  s .c o m*/
}
  • A. this program will print the following: en en_in th_th_th_#u-nu-thai th_th_th_#u-nu-thai.
  • B. this program will print the following: en en_in th_th_th_#u-nu-thai (followed by a runtime exception).
  • C. this program results in a compiler error at statement #1.
  • D. this program results in a compiler error at statement #2.
  • e. this program results in a compiler error at statement #3.
  • F. this program results in a compiler error at statement #4.


F.

Note

the Locale class supports three constructors that are used in statements #1, #2, and #3; however, there is no constructor in the Locale class that takes another Locale object as argument, so the compiler gives an error for statement #4.




PreviousNext

Related