Question 7

Given:
1Z0-829 dumps exhibit
Which two should the module-info file include for it to represent the service provider interface?

Correct Answer:BE
The answer is B and E because the module-info file should include a
provides directive and an exports directive to represent the service provider interface. The provides directive declares that the module provides an implementation of a service interface, which is com.transport.vehicle.cars.Car in this case. The with clause specifies the fully qualified name of the service provider class, which is com.transport.vehicle.cars.impl.CarImpl in this case. The exports directive declares that the module exports a package, which is com.transport.vehicle.cars in this case, to make it available to other modules. The package contains the service interface that other modules can use.
Option A is incorrect because requires is not the correct keyword to declare a service provider interface. Requires declares that the module depends on another module, which is not the case here.
Option C is incorrect because it has a typo in the module name. It should be com.transport.vehicle.cars, not cm.transport.vehicle.cars.
Option D is incorrect because it has a typo in the keyword provides. It should be provides, not Provides. It also has a typo in the service interface name. It should be com.transport.vehicle.cars.Car, not com.transport.vehicle.cars.Car impl. It also has an unnecessary to clause, which is used to limit the accessibility of an exported package to specific modules.
Option F is incorrect because it exports the wrong package. It should export com.transport.vehicle.cars, not com.transport.vehicle.cars.impl. The impl package contains the service provider class, which should not be exposed to other modules.
Option G is incorrect because it exports the wrong package. It should export com.transport.vehicle.cars, not com.transport.vehicle. The vehicle package does not contain the service interface or the service provider class. References:
✑ Oracle Certified Professional: Java SE 17 Developer
✑ Java SE 17 Developer
✑ OCP Oracle Certified Professional Java SE 17 Developer Study Guide
✑ Java Modules - Service Interface Module - GeeksforGeeks
✑ Java Service Provider Interface | Baeldung

Question 8

Given the directory structure:
1Z0-829 dumps exhibit
Given the definition of the Doc class:
1Z0-829 dumps exhibit
Which two are valid definition of the wordDoc class?

Correct Answer:AF
The correct answer is A and F because the wordDoc class must be a non-sealed class or a final class to extend the sealed Doc class. Option B is incorrect because the wordDoc class must be non-sealed or final. Option C is incorrect because the wordDoc class cannot be in a different package than the Doc class. Option D is incorrect because the wordDoc class cannot be a sealed class. Option E is incorrect because the wordDoc class cannot be an abstract class. References: Oracle Certified Professional: Java SE 17 Developer, 3 Sealed Classes - Oracle Help Center

Question 9

Given the code fragment:
1Z0-829 dumps exhibit
What is the result?

Correct Answer:A
The code fragment is using the stream methods allMatch, anyMatch, noneMatch, and findFirst on a list of strings called specialDays. These methods are used to perform matching operations on the elements of a stream, such as checking if all, any, or none of the elements satisfy a given predicate, or finding the first element that matches a predicate1. The predicate in this case is that the string equals ??Labour?? or ??Halloween??. The output will be:
✑ False: because not all of the elements in specialDays are equal to ??Labour?? or ??Halloween??.
✑ true: because at least one of the elements in specialDays is equal to ??Labour?? or ??Halloween??.
✑ true: because none of the elements in specialDays are equal to both ??Labour?? and ??Halloween??.
✑ Optional[NewYear]: because the first element in specialDays that matches the predicate is ??NewYear??, and the findFirst method returns an Optional object that may or may not contain a non-null value2.
References: Stream (Java SE 17 & JDK 17), Optional (Java SE 17 & JDK 17)

Question 10

Given the code fragment:
1Z0-829 dumps exhibit
Which action enables the code to compile?

Correct Answer:E
The code will compile if the regNo variable is made public. This is because the regNo variable is being accessed in the main method of the App class, which is outside the scope of the Product class. Making the regNo variable public will allow it to be accessed from outside the class. References: https://education.oracle.com/products/trackp_OCPJSE17, https://mylearn.oracle.com/ou/learning-path/java-se-17-developer/99487, https://docs.oracle.com/javase/tutorial/java/javaOO/accesscontrol.html

Question 11

Given:
1Z0-829 dumps exhibit
What is the result?

Correct Answer:B
The answer is B because the code uses the writeObject and readObject methods of
the ObjectOutputStream and ObjectInputStream classes to serialize and deserialize the Game object. These methods use the default serialization mechanism, which writes and reads the state of the object??s fields, including the inherited ones. Therefore, the title field of the Software class is also serialized and deserialized along with the players field of the Game class. The toString method of the Game class calls the toString method of the Software class using super.toString(), which returns the value of the title field. Hence, when the deserialized object is printed, it shows ??Software Game Software Game Chess 2??. References:
✑ Oracle Certified Professional: Java SE 17 Developer
✑ Java SE 17 Developer
✑ OCP Oracle Certified Professional Java SE 17 Developer Study Guide
✑ Serialization and Deserialization in Java with Example

Question 12

Given:
1Z0-829 dumps exhibit
What is the result

Correct Answer:C
The code fragment is using the switch statement with the new Java 17 syntax. The switch statement checks the value of the variable desig and executes the corresponding case statement. In this case, the value of desig is ??CTO??, which does not match any of the case labels. Therefore, the default case statement is executed, which prints ??Undefined??. The other case statements are not executed, because there is no fall through in the new syntax. Therefore, the output of the code fragment is: Undefined

START 1z0-829 EXAM