Oracle Certified Associate Java Se 8 Programmer · Free Practice Question Hard
Question 24
Consider below code:
- //Test.java
- package com.udayan.oca;
- import java.time.LocalDate;
- public class Test {
- public static void main(String [] args) {
- LocalDate newYear = LocalDate.of(2018, 1, 1);
- LocalDate eventDate = LocalDate.of(2018, 1, 1);
- boolean flag1 = newYear.isAfter(eventDate);
- boolean flag2 = newYear.isBefore(eventDate);
- System.out.println(flag1 + ":" + flag2);
- }
- }
What will be the result of compiling and executing Test class?
-
A
true:false
-
B
true:true
-
C
false:true
-
D
false:false
Reveal correct answer
Correct answer: D
Explanation
isAfter and isBefore method can be interpreted as:
Does 1st Jan 2018 come after 1st Jan 2018? No, false. Does 1st Jan 2018 come before 1st Jan 2018? No, false.
Discussion
Think the marked answer is wrong, or have a better explanation? Share it below — comments appear after review.
You must be logged in to post a comment.
