Premium

Oracle Advacned Java Advanced Certification Questions and Answers (Dumps and Practice Questions)



Question : You have been given below code, what is the expected output?

package com.hadoopexam;

import java.time.LocalDate;
import java.time.Month;

public class Welcome {

public static void main(String[] args) {
LocalDate birthDate = LocalDate.of(1969, Month.JANUARY, 01);
LocalDate atFiftyYears = birthDate.plusYears(50);
atFiftyYears.plusDays(15); // line n1
System.out.println(atFiftyYears);
}
}
 : You have been given below code, what is the expected output?
1. 2019-01-16

2. 2019-01-01

3. Access Mostly Uused Products by 50000+ Subscribers

4. A DateTimeExceptionis thrown.


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.

LocalDate java.time.LocalDate.plusDays(long daysToAdd)

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?

package com.hadoopexam;

import java.util.function.BiFunction;

public class Welcome {

public static void main(String[] args) {
BiFunction summation = (value1, value2) -> value1 + value2;//n1
System.out.println(summation.apply(1, 2.5)); //n2
}
}
 : You have been given below code, what is the expected behavior?
1. 3.5

2. 1

3. Access Mostly Uused Products by 50000+ Subscribers

4. A compilation error occurs at line n2.


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?


 : Which statement is true about java.time.Duration?
1. It tracks time zones.

2. It preserves daylight saving time.

3. Access Mostly Uused Products by 50000+ Subscribers

4. It defines date-based values.


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.



Related Questions


Question : Which statement is true about the single abstract method of the java.util.function.Function interface?


 : Which statement is true about the single abstract method of the java.util.function.Function interface?
1. It accepts one argument and returns void.

2. It accepts one argument and returns boolean.

3. Access Mostly Uused Products by 50000+ Subscribers

4. It accepts an argument and produces a result of any data type.



Question : Which statement is true about the DriverManager class?


 : Which statement is true about the DriverManager class?
1. It returns an instance of Connection.

2. it executes SQL statements against the database.

3. Access Mostly Uused Products by 50000+ Subscribers

4. it is written by different vendors for their specific database



Question : You have been given below code, how will you replace n , so that it will print maximum value from given list?

package com.hadoopexam;
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;

public class Welcome {


public static void main(String[] args) {
List nums = Arrays.asList (101, 201, 108);
System.out.println (
//line n1

);
}
}
 : You have been given below code, how will you replace n , so that it will print maximum value from given list?
1. nums.stream().max(Comparator.comparing(a -> a)).get()

2. nums.stream().max(Integer :: max).get()

3. Access Mostly Uused Products by 50000+ Subscribers

4. nums.stream().map(a -> a).max();



Question : You have been given below code, what is the expected behavior. All are in same package?

class Parent {
public final void call(int min, int temp) {
}

public void mix() {
}
}
public final class Peer {
public void peerMethod() {
}
}

public class Peer2 {
private Parent c = new Parent();
private final double discount = 0.25;

public void peer2Call() {
c.call(10, 120);
}
}

public class Child1 extends Parent {
public void call(int minutes, int temperature) {}
public void childMethod() {
}
}

 : You have been given below code, what is the expected behavior. All are in same package?
1. A compilation error occurs in Parent.

2. A compilation error occurs in Peer.

3. Access Mostly Uused Products by 50000+ Subscribers

4. A compilation error occurs in Child1

5. All classes compile successfully.



Question : Which two statements are true about localizing an application?
A. Support for new regional languages does not require recompilation of the code.
B. Textual elements (messages and GUI labels) are hard-coded in the code.
C. Language and region-specific programs are created using localized data.
D. Resource bundle files include data and currency information.
E. Language codes use lowercase letters and region codes use uppercase letters.

 : Which two statements are true about localizing an application?
1. A,B
2. B,C
3. Access Mostly Uused Products by 50000+ Subscribers
4. D,E
5. A,E


Question : Which statement is true about java.util.stream.Stream?


 : Which statement is true about java.util.stream.Stream?
1. A stream cannot be consumed more than once.

2. The execution mode of streams can be changed during processing.

3. Access Mostly Uused Products by 50000+ Subscribers

4. A parallel stream is always faster than an equivalent sequential stream