Java OCA OCP Practice Question 2799

Question

Given that "it, IT" is the locale code for Italy and that "pt, BR" is the locale code for Brazil, and given:

51.  Date d = new Date();  
52.  DateFormat df = DateFormat.getDateInstance(DateFormat.FULL);  
53.  Locale[] la = {new Locale("it", "IT"), new Locale("pt", "BR")};      
54.  for(Locale l: la) {  
55.    df.setLocale(l);  
56.    System.out.println(df.format(d));  
57.  } 

Which are true? (Choose all that apply.)

  • A. An exception is thrown at runtime.
  • B. Compilation fails due to an error on line 53.
  • C. Compilation fails due to an error on line 55.
  • D. Compilation fails due to an error on line 56.
  • E. The output will contain only today's date for the Italian locale.
  • F. The output will contain today's date for both Italian and Brazilian locales.


C is correct.

Note

Any instance of DateFormat has an immutable Locale-in other words, there is no setLocale() method.

The rest of the code is legal.




PreviousNext

Related