Leave a Reply 5

Your email address will not be published. Required fields are marked *


renko

renko

Answer: C
package q084;
import java.time.LocalDate;

public class Test {

public static void main(String[] args) {
LocalDate date1 = LocalDate.now();
LocalDate date2 = LocalDate.of(2014, 6, 20);
//Compile error => Answer C
LocalDate date3 = LocalDate.parse(“2014-06-20”, DateTimeFormatter.ISO_DATE);
//this one compiles file => Answer: A
//LocalDate date4 = LocalDate.parse(“2014-06-20”);//, DateTimeFormatter.ISO_DATE);
System.out.println(“date1 = “+ date1);
System.out.println(“date2 = “+ date2);
System.out.println(“date3 = “+ date3);
//System.out.println(“date3 = “+ date4);
}

}
/*Output
Exception in thread “main” java.lang.Error: Unresolved compilation problem:
DateTimeFormatter cannot be resolved to a variable

at q084.Test.main(Test.java:10)*/

AGO

AGO

Answer A. you didnt import : import java.time.format.DateTimeFormatter;

renko

renko

You are wright, A is the answer.
Thank you

Snr DingDong

Snr DingDong

Correct answer is A

Check your syntax imports. You forgot to import
import java.time.format.DateTimeFormatter;

if you import that you will see the answer is A