Correct Answer : Get Lastest Questions and Answer : Explanation: We will get copy of the LocalDate object. Original object remain as it is with plusDays method.
Returns a copy of this LocalDate with the specified number of days added. This method adds the specified amount to the days field incrementing the month and year fields as necessary to ensure the result remains valid. The result is only invalid if the maximum/minimum year is exceeded. For example, 2008-12-31 plus one day would result in 2009-01-01. This instance is immutable and unaffected by this method call. Parameters: daysToAdd the days to add, may be negative Returns: a LocalDate based on this date with the days added, not null Throws: DateTimeException - if the result exceeds the supported date range
Question : You have been given below code, what is the expected behavior?
Correct Answer : Get Lastest Questions and Answer : Explanation: value1 +value2 (Integer + Double) will produce double. But expected return type is Integer. java.util.function.BiFunction
@FunctionalInterface Represents a function that accepts two arguments and produces a result. This is the two-arity specialization of Function. This is a functional interface whose functional method is apply(Object, Object). Parameters: the type of the first argument to the function the type of the second argument to the function the type of the result of the function
Question : Which statement is true about java.time.Duration?
Correct Answer : Get Lastest Questions and Answer : Explanation: The Duration class represents time in terms of hours, minutes, seconds, and so on. It is suitable for measuring machine time or when working with Instance objects. Similar to the Instance class, the Duration class stores the seconds component as a long value and nanoseconds using an int value.
The java.time.Duration class represents time in terms of hours, minutes, seconds, and fraction of seconds.
The Duration class is for time-based values in terms of quantity of time (such as seconds, minutes, and hours). The Period class is for date-based values such as years, months, and days.