Weekend Sale 65% Discount Offer - Ends in 0d 00h 00m 00s - Coupon code: sale65best

Free Oracle 1z0-830 Practice Exam with Questions & Answers | Set: 3

Questions 21

Which three of the following are correct about the Java module system?

Options:
A.

Code in an explicitly named module can access types in the unnamed module.

B.

The unnamed module exports all of its packages.

C.

If a package is defined in both a named module and the unnamed module, then the package in the unnamed module is ignored.

D.

We must add a module descriptor to make an application developed using a Java version prior to SE9 run on Java 11.

E.

The unnamed module can only access packages defined in the unnamed module.

F.

If a request is made to load a type whose package is not defined in any known module, then the module system will attempt to load it from the classpath.

Oracle 1z0-830 Premium Access
Questions 22

Given:

var cabarets = new TreeMap<>();

cabarets.put(1, "Moulin Rouge");

cabarets.put(2, "Crazy Horse");

cabarets.put(3, "Paradis Latin");

cabarets.put(4, "Le Lido");

cabarets.put(5, "Folies Bergère");

System.out.println(cabarets.subMap(2, true, 5, false));

What is printed?

Options:
A.

CopyEdit

{2=Crazy Horse, 3=Paradis Latin, 4=Le Lido, 5=Folies Bergère}

B.

{2=Crazy Horse, 3=Paradis Latin, 4=Le Lido}

C.

{}

D.

An exception is thrown at runtime.

E.

Compilation fails.

Questions 23

Given:

java

import java.io.*;

class A implements Serializable {

int number = 1;

}

class B implements Serializable {

int number = 2;

}

public class Test {

public static void main(String[] args) throws Exception {

File file = new File("o.ser");

A a = new A();

var oos = new ObjectOutputStream(new FileOutputStream(file));

oos.writeObject(a);

oos.close();

var ois = new ObjectInputStream(new FileInputStream(file));

B b = (B) ois.readObject();

ois.close();

System.out.println(b.number);

}

}

What is the given program's output?

Options:
A.

1

B.

2

C.

Compilation fails

D.

ClassCastException

E.

NotSerializableException

Questions 24

Given:

java

package com.vv;

import java.time.LocalDate;

public class FetchService {

public static void main(String[] args) throws Exception {

FetchService service = new FetchService();

String ack = service.fetch();

LocalDate date = service.fetch();

System.out.println(ack + " the " + date.toString());

}

public String fetch() {

return "ok";

}

public LocalDate fetch() {

return LocalDate.now();

}

}

What will be the output?

Options:
A.

ok the 2024-07-10T07:17:45.523939600

B.

Compilation fails

C.

An exception is thrown

D.

ok the 2024-07-10

Questions 25

Given:

java

int post = 5;

int pre = 5;

int postResult = post++ + 10;

int preResult = ++pre + 10;

System.out.println("postResult: " + postResult +

", preResult: " + preResult +

", Final value of post: " + post +

", Final value of pre: " + pre);

What is printed?

Options:
A.

postResult: 15, preResult: 16, Final value of post: 6, Final value of pre: 6

B.

postResult: 16, preResult: 16, Final value of post: 6, Final value of pre: 6

C.

postResult: 15, preResult: 16, Final value of post: 5, Final value of pre: 6

D.

postResult: 16, preResult: 15, Final value of post: 6, Final value of pre: 5