Given the code fragment:
What is the result?
Given the code fragment:
What is the result?
The code will not run due to a compilation error. The method format is being invoked without a dot (.) separator from the object, leading to a syntactically invalid line of code. This will result in a compilation error rather than an exception at runtime. The code would work if it was written correctly as: System.out.print(dt.format(DateTimeFormatter.ISO_DATE)); even though the suggested modifications of the date are also incorrect and would not be saved due to the immutability of LocalDateTime objects.
Agree, the correct answer C 2014-07-31; System.out.println(dt.format(DateTimeFormatter.ISO_DATE));
Answer is C (Fixing punctuation and whitespace). To test: public static void main(String[] args) { LocalDateTime dt = LocalDateTime.of(2014, 7, 31, 1, 1); dt.plusDays(30); dt.plusMonths(1); System.out.print(dt.format(DateTimeFormatter.ISO_DATE)); }
LocalDateTime cannot convert o LocalDate -> A (maybe the answer is Compilation error)
The correct answer is the letter A, I'll explain why, the code would compile but notice that the last line doesn't have a "." to invoke the "format" method, then the code would not compile, but as it doesn't have the correct answer, I would mark the answer that most closely matches the reality of this code which is an exception, because in it the code doesn't run either.
answer is C: 2014-07-31
answer is.... A
There is type in this case. If it was System.out.println(dt.format(DateTimeFormatter.ISO_DATE)); then the answer is C otherwise compilation error
LocalDateTime is immutable. dt.plusdays(30) saves to no where
LocalDateTime is immutable. dt.plusdays(30) saves to no where
C is correct
ISO_DATE NEEDS TO BE ISO_DATE_TIME
Answer is C
Answer is C
Answer is C. Because dt is immutable. There is no assignment to dt.
Seriously?? error: incompatible types: LocalDateTime cannot be converted to LocalDate LocalDate time = LocalDateTime.of(2021,12,23,12,15);
import java.time.LocalDate; import java.time.LocalDateTime; import java.time.format.DateTimeFormatter; public class Found { public static void main(String[] args) { LocalDateTime dt = LocalDateTime.of(2014, 7,31,1,1); dt.plusDays(30); dt.plusMonths(1); System.out.println(dt.format(DateTimeFormatter.ISO_DATE)); } } 2014-07-31
LocalDateTime is not a subclass of LocalDate.. Answer is A