Premium

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



Question : You have been given the below code, what is the behavior you expect.

package com.hadoopexam;

import java.util.ArrayDeque;
import java.util.Arrays;
import java.util.Deque;

class Welcome {
public static void main(String[] args) {
Deque deque = new ArrayDeque<>();
deque.addAll(Arrays.asList(1, 2, 3, 4, 5));
System.out.println("First removed element is = " + deque.remove());
}
}
 : You have been given the below code, what is the behavior you expect.
1. Code will through compile time exception.

2. Code will compile but through Runtime exception "IllegalStateException"

3. Code will compile and run perfectly and print First removed element is = 5

4. Code will compile and run perfectly and print First removed element is = 1


Correct Answer : Get Lastest Questions and Answer :
Explanation: As remove() method will remove the first element from Deque .




Question : You have been given below code. Select the correct behavior of the code.

package com.hadoopexam;

class Parent {

private T test;
void call(T t) {
test = t;
System.out.println("Testing Method 1");
}
}



package com.hadoopexam;

class Welcome extends Parent {
public Welcome(S s) {
}

void call(S s) {
System.out.println("Testing Method 2");
}
}

package com.hadoopexam;

class Test {
public static void main(String[] args) {
Welcome err = new Welcome("Test");
err.call("Calling");
}
}

 : You have been given below code. Select the correct behavior of the code.
1. Code will compile and run with the output as "Testing Method 2"

2. Code will compile and run with the output as "Testing Method 1"

3. Access Mostly Uused Products by 50000+ Subscribers

4. Code will not compile because there is an ambiguity in code call method


Correct Answer : Get Lastest Questions and Answer :
Explanation: When code check compile time there are two methods defined call(S s) and call(T t). And no datatype is defined for them. Hence, compile will see signature of
the methods as call (String) and call(S extends CharSequence) and they would be considered as overloaded method and not overridden method. Having the same signature for overloaded
method it will through compile time exception considering the ambiguity.




Question : Select the correct functional interface from below.

A. java.util.stream.Stream
B. java.util.function.Consumer
C. java.util.function.Supplier
D. java.util.function.Predicate
E. java.util.function.Function

 : Select the correct functional interface from below.
1. A,B,C
2. B,C,D
3. Access Mostly Uused Products by 50000+ Subscribers
4. A,D,E
5. B,C,D,E

Correct Answer : Get Lastest Questions and Answer :
Explanation: The interface java.util.stream.Stream is not a functional interface-it has
numerous abstract methods. The other four options are functional interfaces.
The functional interface java.util.function.Consumer has an abstract method
with the signature void accept(T t);
The functional interface java.util.function.Supplier has an abstract method
with the signature T get();
The functional interface java.util.function.Predicate has an abstract method
with the signature boolean test(T t);
The functional interface java.util.function.Function has an abstract
method with the signature R apply(T t);



Related Questions


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

package com.hadoopexam;

import java.nio.file.FileAlreadyExistsException;

class Welcome {
@SuppressWarnings("finally")
public static void call() throws Exception {
try {
throw new FileAlreadyExistsException(null);
} finally {
throw new Exception();
}
}

public static void main(String[] args) {
try {
call();
} catch (Throwable throwable) {
System.out.println(throwable);
}
}
}

 : You have been given below code, what is the behavior expected?
1. It will not compile

2. It will compile and run with Throwable

3. Access Mostly Uused Products by 50000+ Subscribers

4. It will compile and run with no output

5. It will compile and run with FileAlreadyExistsException



Question : You have been given following code, what is the behavior expected

package com.hadoopexam;

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

class Welcome {
public static void main(String[] args) {
LocalDate date1 = LocalDate.of(2014, Month.MARCH, 01);
LocalDate date2 = LocalDate.of(2016, Month.NOVEMBER, 01);
System.out.println(Period.between(date2, date1).getYears());
}
}
 : You have been given following code, what is the behavior expected
1. It will give compile time error

2. It will compile and run perfectly and print 1

3. Access Mostly Uused Products by 50000+ Subscribers

4. It will compile and run perfectly and print -1

5. It will compile and run perfectly and print -2



Question : Which one of the following classes is best suited for storing timestamp values of application events in a file?
 : Which one of the following classes is best suited for storing timestamp values of application events in a file?
1. java.time.ZoneId class

2. java.time.ZoneOffset class

3. Access Mostly Uused Products by 50000+ Subscribers

4. java.time.Duration class

5. java.time.Period class



Question : You have been given below code, what is the expected behavior?
package com.hadoopexam;

import java.time.LocalDateTime;
import java.time.ZoneId;
import java.time.ZonedDateTime;

class Welcome {
public static void main(String[] args) {
ZoneId zoneId = ZoneId.of("Asia/Kolkata");
ZonedDateTime zonedDateTime = ZonedDateTime.of(LocalDateTime.now(), zoneId);
System.out.println(zonedDateTime.getOffset());
}
}
 : You have been given below code, what is the expected behavior?
1. It will not compile.

2. It will compile and print +5:30[Asia/Kolkata]

3. Access Mostly Uused Products by 50000+ Subscribers

4. It will compile and print +5:30[UTC]

5. It will compile and print +5:30



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

package com.hadoopexam;

import java.time.LocalDate;
import java.time.Month;
import java.time.format.DateTimeFormatter;

class Welcome {
public static void main(String[] args) {
DateTimeFormatter dateFormat = DateTimeFormatter.ISO_DATE;
LocalDate dateOfBirth = LocalDate.of(2016, Month.FEBRUARY, 29);
System.out.println(dateFormat.format(dateOfBirth));
}
}
 : You have been given below code, what behavior is expected?
1. It will give compile time error.

2. It will produce output as '2016-02-29'

3. Access Mostly Uused Products by 50000+ Subscribers

4. It will produce output as '2016-Feb-29'



Question : You have been given following code, and running from a system which are installed in India on Saturday and month is November and Year is . What will be the behavior
of the code?
package com.hadoopexam;

import java.time.LocalDateTime;
import java.time.format.DateTimeFormatter;
import java.util.Locale;

class Welcome {
public static void main(String[] args) {
DateTimeFormatter formatter = DateTimeFormatter.ofPattern("EEEE",Locale.US);
System.out.println(formatter.format(LocalDateTime.now()));
}
}
 : You have been given following code, and running from a system which are installed in India on Saturday and month is November and Year is . What will be the behavior
1. It will not compile.

2. It will print NOVEMBER

3. Access Mostly Uused Products by 50000+ Subscribers

4. It will print Satu.