Campbell Ritchie wrote:
[Edit] Your first code block has four quotes on line 4! I think you have copied it wrongly.
Both backslashes on line 13 can be removed since this is a text block. Additionally, the second and third backslashes on line 14 can be removed. The first one must be retained since there are three quotes in a row.
An Instant represents a specific moment in time using GMT. Since there are no time zones included, options A and C are incorrect. This code correctly adds one day to the instant. It includes the date, making option F correct.
(I would note that the introduction of lambdas has made me much more tempted to put braces on the same line for short statements.)
Then too, I am a big fan of using ternary operators like this:
Which may be less "readable" to people not used to seeing it. But I find readability is often subjective, and based on what you are used to seeing. I encourage people to expand their notion of readability to include chained ternary operators, mimicking the else if structure we already accept.
It is an age old problem in programming languages.
https://en.wikipedia.org/wiki/Dangling_else
Specifically, for Java: https://stackoverflow.com/questions/32076762/java-statements-processing-precedence-dangling-else
7. Which of the following are correct? (Choose all that apply.)
A. A local variable of type boolean defaults to null.
B. A local variable of type float defaults to 0.0f.
C. A local variable of type double defaults to 0.
D. A local variable of type Object defaults to null.
E. A local variable of type boolean defaults to false.
F. A local variable of type float defaults to 0.0.
G. None of the above
If this question were about instance variables, options B, D, and E would be correct. A boolean primitive defaults to false, and a float primitive defaults to 0.0f.