2024年最新ののOracle 1z1-829問題集PDF1z1-829最速合格したいならここ
1z1-829練習試験問題集で99%合格率Oracle試験合格させます
質問 # 12
Given the code fragment:
Which code line n1, obtains the java.io.Console object?
- A.

- B.

- C.

- D.

- E.

正解:B
解説:
Explanation
The code fragment is trying to obtain the java.io.Console object, which is a class that provides methods to access the character-based console device, if any, associated with the current Java virtual machine. The correct way to obtain the Console object is to call the static method Console console() in the java.lang.System class.
This method returns the unique Console object associated with the current Java virtual machine, if any.
Therefore, option A is correct, as it calls System.console() and assigns it to a Console variable. References:
https://docs.oracle.com/javase/17/docs/api/java.base/java/io/Console.html
https://docs.oracle.com/javase/17/docs/api/java.base/java/lang/System.html#console()
https://education.oracle.com/products/trackp_OCPJSE17
https://mylearn.oracle.com/ou/learning-path/java-se-17-developer/99487
質問 # 13
Given:
What is the result?
- A. 101
101
1000 - B. 1001
100
1000 - C. 100
100
1000 - D. 1001
1001
1000
正解:B
解説:
Explanation
The code fragment is using the bitwise operators & (AND), | (OR), and ^ (XOR) to perform operations on the binary representations of the integer values. The & operator returns a 1 in each bit position where both operands have a 1, the | operator returns a 1 in each bit position where either operand has a 1, and the ^ operator returns a 1 in each bit position where only one operand has a 1. The binary representations of the integer values are as follows:
1000 = 1111101000
100 = 1100100
101 = 1100101
The code fragment performs the following operations:
x = x ^ y; // x becomes 1111010101, which is 1001 in decimal
y = x ^ y; // y becomes 1100100, which is 100 in decimal
x = x ^ y; // x becomes 1100101, which is 101 in decimal
The code fragment then prints out the values of x, y, and z, which are 1001, 100, and 1000 respectively.
Therefore, option D is correct.
質問 # 14
Given the code fragment:
What is the result?
- A. Logged out at: 2021-0112T21:58:19.880z
- B. Can't logout
- C. A compilation error occurs at Line n1.
- D. Logged out at: 2021-01-12T21:58:00z
正解:D
解説:
The code fragment is using the Java SE 17 API to get the current time and then truncating it to minutes. The result will be the current time truncated to minutes, which is why option B is correct. Reference:
https://education.oracle.com/products/trackp_OCPJSE17
https://mylearn.oracle.com/ou/learning-path/java-se-17-developer/99487
https://docs.oracle.com/javase/17/docs/api/java.base/java/time/Instant.html#truncatedTo(java.time.temporal.TemporalUnit)
質問 # 15
Which statement is true about migration?
- A. Every module is moved to the module path in a bottom-up migration.
- B. Every module is moved to the module path in a top-down migration.
- C. Unnamed modules are automatic modules in a top-down migration.
- D. The required modules migrate before the modules that depend on them in a top-down ^migration.
正解:A
解説:
Explanation
The answer is B because a bottom-up migration is a strategy for modularizing an existing application by moving its dependencies to the module path one by one, starting from the lowest-level libraries and ending with the application itself. This way, each module can declare its dependencies on other modules using the module-info.java file, and benefit from the features of the Java Platform Module System (JPMS), such as reliable configuration, strong encapsulation, and service loading.
Option A is incorrect because a top-down migration is a strategy for modularizing an existing application by moving it to the module path first, along with its dependencies as automatic modules. Automatic modules are non-modular JAR files that are treated as modules with some limitations, such as not having a module descriptor or a fixed name. A top-down migration allows the application to use the module path without requiring all of its dependencies to be modularized first.
Option C is incorrect because a top-down migration does not require any specific order of migrating modules, as long as the application is moved first and its dependencies are moved as automatic modules. A bottom-up migration, on the other hand, requires the required modules to migrate before the modules that depend on them.
Option D is incorrect because unnamed modules are not automatic modules in any migration strategy.
Unnamed modules are modules that do not have a name or a module descriptor, such as classes loaded from the class path or dynamically generated classes. Unnamed modules have unrestricted access to all other modules, but they cannot be accessed by named modules, except through reflection with reduced security checks. References:
Oracle Certified Professional: Java SE 17 Developer
Java SE 17 Developer
OCP Oracle Certified Professional Java SE 17 Developer Study Guide
Migrating to Modules (How and When) - JavaDeploy
Java 9 Modularity: Patterns and Practices for Developing Maintainable Applications
質問 # 16
Given the code fragment:
Which code fragment returns different values?
- A. int sum = listOfNumbers. parallelStream () reduce (5, Integer:: sum) ;
- B. int sum = listOfNumbers. parallelStream () reduce ({m, n) -> m +n) orElse (5) +5;
- C. int sum = listOfNumbers. Stream () reduce (0, Integer:: sum) + 5
- D. int sum = listOfNumbers. Stream () reduce (5, (a, b) -> a + b) ;
- E. int sum = listOfNumbers. Stream () reduce ( Integer:: sum) ; +5;
正解:E
解説:
The answer is C because the code fragment uses a different syntax and logic for the reduce operation than the other options. The reduce method in option C takes a single parameter, which is a BinaryOperator that combines two elements of the stream into one. The method returns an Optional, which may or may not contain a value depending on whether the stream is empty or not. The code fragment then adds 5 to the result of the reduce method, regardless of whether it is present or not. This may cause an exception if the Optional is empty, or produce a different value than the other options if the Optional is not empty.
The other options use a different syntax and logic for the reduce operation. They all take two parameters, which are an identity value and a BinaryOperator that combines an element of the stream with an accumulator. The method returns the final accumulator value, which is equal to the identity value if the stream is empty, or the result of applying the BinaryOperator to all elements of the stream otherwise. The code fragments then add 5 to the result of the reduce method, which will always produce a valid value.
For example, suppose listOfNumbers contains [1, 2, 3]. Then, option A will perform the following steps:
Initialize accumulator to identity value 5
Apply BinaryOperator Integer::sum to accumulator and first element: 5 + 1 = 6 Update accumulator to 6 Apply BinaryOperator Integer::sum to accumulator and second element: 6 + 2 = 8 Update accumulator to 8 Apply BinaryOperator Integer::sum to accumulator and third element: 8 + 3 = 11 Update accumulator to 11 Return final accumulator value 11 Add 5 to final accumulator value: 11 + 5 = 16 Option B will perform the same steps as option A, except using a lambda expression instead of a method reference for the BinaryOperator. Option D will perform the same steps as option A, except using parallelStream instead of stream, which may change the order of applying the BinaryOperator but not the final result. Option E will perform the same steps as option A, except using identity value 0 instead of 5.
Option C, however, will perform the following steps:
Apply BinaryOperator Integer::sum to first and second element: 1 + 2 = 3 Apply BinaryOperator Integer::sum to previous result and third element: 3 + 3 = 6 Return Optional containing final result value 6 Add 5 to Optional value: Optional.of(6) + 5 = Optional.of(11) As you can see, option C produces a different value than the other options, and also uses a different syntax and logic for the reduce operation. Reference:
Oracle Certified Professional: Java SE 17 Developer
Java SE 17 Developer
OCP Oracle Certified Professional Java SE 17 Developer Study Guide
Guide to Stream.reduce()
質問 # 17
Given the code fragment:
- A. True:false:false:false
- B. True:false:true:false
- C. True:true:false:false
- D. True:false:true:true
正解:B
解説:
Explanation
The code fragment compares four pairs of strings using the equals() and intern() methods. The equals() method compares the content of two strings, while the intern() method returns a canonical representation of a string, which means that it returns a reference to an existing string with the same content in the string pool. The string pool is a memory area where strings are stored and reused to save space and improve performance. The results of the comparisons are as follows:
s1.equals(s2): This returns true because both s1 and s2 have the same content, "Hello Java 17".
s1 == s2: This returns false because s1 and s2 are different objects with different references, even though they have the same content. The == operator compares the references of two objects, not their content.
s1.intern() == s2.intern(): This returns true because both s1.intern() and s2.intern() return a reference to the same string object in the string pool, which has the content "Hello Java 17". The intern() method ensures that there is only one copy of each distinct string value in the string pool.
"Hello Java 17" == s2: This returns false because "Hello Java 17" is a string literal, which is automatically interned and stored in the string pool, while s2 is a string object created with the new operator, which is not interned by default and stored in the heap. Therefore, they have different references and are not equal using the == operator.
References: String (Java SE 17 & JDK 17) - Oracle
質問 # 18
Given:
What is the result?
- A. A RuntimeException is thrown
- B. Wtablechair tableChair
- C. Tablechair Tablechair
- D. Compilation fails
- E. wTableChair TableChair
正解:D
解説:
The code fragment will fail to compile because the class name and the constructor name do not match. The class name is Furniture, but the constructor name is Wtable. This will cause a syntax error. The correct way to define a constructor is to use the same name as the class name. Therefore, the code fragment should change the constructor name to Furniture or change the class name to Wtable.
質問 # 19
Given:
What is the result?
- A. B A D
- B. B A C
- C. D D D
- D. D A D
正解:A
解説:
Explanation
The answer is C because the code demonstrates the concept of method overloading and type conversion in Java. Method overloading allows different methods to have the same name but different parameters. Type conversion allows values of one data type to be assigned to another data type, either automatically or explicitly. In the code, the class Test has four methods named sum, each with different parameter types: int, float, and double. The main method creates an instance of Test and calls the sum method with different arguments. The compiler will choose the most specific method that matches the arguments, based on the following rules:
If there is an exact match between the argument types and the parameter types, that method is chosen.
If there is no exact match, but there is a method with compatible parameter types, that method is chosen.
Compatible types are those that can be converted from one to another automatically, such as int to long or float to double.
If there is more than one method with compatible parameter types, the most specific method is chosen.
The most specific method is the one whose parameter types are closest to the argument types in terms of size or precision.
In the code, the following method calls are made:
test.sum(10, 10.5) -> This matches the sum(int a, float b) method exactly, so it is chosen.
The result is 20.5, which is converted to int and printed as 20 (B).
test.sum(10) -> This does not match any method exactly, but it matches the sum(double a) method with compatible types, as int can be converted to double automatically. The result is 10.0, which is printed as 10
(A). test.sum(10.5, 10) -> This does not match any method exactly, but it matches two methods with compatible types: sum(float a, float b) and sum(double a, double b). The latter is more specific, as double is closer to the argument types than float. The result is 20.5, which is printed as 20 (D).
Therefore, the output is B A D. References
Oracle Certified Professional: Java SE 17 Developer
Java SE 17 Developer
OCP Oracle Certified Professional Java SE 17 Developer Study Guide
Method Overloading in Java
Type conversion in Java with Examples
Java Method Overloading with automatic type conversions
質問 # 20
Given the course table:
Given the code fragment:
- A. true
- B. false
- C. 0
- D. 1
正解:A
解説:
The code fragment will execute the update statement and set the course fee of the course with ID 1021 to 5000. The executeUpdate method returns an int value that indicates the number of rows affected by the SQL statement. In this case, only one row will be updated, so the result variable will be 1. The if statement will check if the result is greater than 0, which is true, and print "Updated successfully". Therefore, the output of the code fragment is true. Reference: https://education.oracle.com/products/trackp_OCPJSE17, https://mylearn.oracle.com/ou/learning-path/java-se-17-developer/99487, https://docs.oracle.com/en/java/javase/17/docs/api/java.sql/java/sql/Statement.html#executeUpdate(java.lang.String)
質問 # 21
Given:
Which action enables the code to compile?
- A. Replace 15 with item.display (''Flower'');
- B. Replace 7 with public void display (string design) {
- C. Replace 3 with private static void display () {
- D. Replace 2 with static string name;
正解:B
解説:
The answer is C because the code fragment contains a syntax error in line 7, where the method display is declared without any parameter type. This causes a compilation error, as Java requires the parameter type to be specified for each method parameter. To fix this error, the parameter type should be added before the parameter name, such as string design. This will enable the code to compile and run without any errors. Reference:
Oracle Certified Professional: Java SE 17 Developer
Java SE 17 Developer
OCP Oracle Certified Professional Java SE 17 Developer Study Guide
Java Methods
質問 # 22
Which statement is true?
- A. The tryLock () method returns a boolean indicator immediately regardless if it has or has not managed to acquire the lock.
- B. The tryLock () method returns a boolean indicator immediately if it has managed to acquire the lock, otherwise it waits for the lock acquisition.
- C. The Lock () method returns a boolean indicator immediately regardless if it has or has not managed to acquire the lock
- D. The lock () method returns a boolean indicator immediately if it has managed to acquire the lock, otherwise it waits for the lock acquisition.
正解:A
解説:
The tryLock () method of the Lock interface is a non-blocking attempt to acquire a lock. It returns true if the lock is available and acquired by the current thread, and false otherwise. It does not wait for the lock to be released by another thread. This is different from the lock () method, which blocks the current thread until the lock is acquired, and does not return any value. Reference: https://docs.oracle.com/en/java/javase/17/docs/api/java.base/java/util/concurrent/locks/Lock.html#tryLock(), 3, 4, 5
質問 # 23
Given the code fragments:
Which action prints Wagon : 200?
- A. At line n2, in the main method signature, add throws IOException, ClassCastException.
- B. At line n1, implement the java.io, Serializable interface.
- C. At line n2, in the main method signature, add throws IoException, ClassNotFoundException.
- D. At line n3, replace readObject (0 with readLine().
- E. At Line n3, replace Car with LuxurayCar.
- F. At Line n1, implement the java.io.AutoCloseable interface
正解:C
解説:
The code fragment is trying to read an object from a file using the ObjectInputStream class. This class throws an IOException and a ClassNotFoundException. To handle these exceptions, the main method signature should declare that it throws these exceptions. Otherwise, the code will not compile. If the main method throws these exceptions, the code will print Wagon : 200, which is the result of calling the toString method of the LuxuryCar object that was written to the file. Reference: ObjectInputStream (Java SE 17 & JDK 17) - Oracle, ObjectOutputStream (Java SE 17 & JDK 17) - Oracle
質問 # 24
Given:
Which two modifications enable the code to print Open Close?
- A.

- B.

- C.

- D.

- E.

正解:B、E
解説:
The code given is a try-with-resources statement that declares a resource of type AutoCloseable. The resource is an anonymous class that implements the AutoCloseable interface and overrides the close() method. The code also has a print() method that prints the value of the variable s. The code is supposed to print "Open Close", but it does not compile because of two errors.
The first error is at line n1, where the anonymous class is missing a semicolon at the end of its declaration. This causes a syntax error and prevents the code from compiling. To fix this error, option B adds a semicolon after the closing curly brace of the anonymous class.
The second error is at line n2, where the print() method is called without an object reference. This causes a compilation error because the print() method is not static and cannot be invoked without an object. To fix this error, option E adds an object reference to the print() method by using the variable t.
Therefore, options B and E are correct and enable the code to print "Open Close".
質問 # 25
Assume you have an automatic module from the module path display-ascii-0.2. jar. Which name is given to the automatic module based on the given JAR file?
- A. Display-ascii
- B. Display-ascii-0.2
- C. Display.ascii
- D. Display-ascii-0
正解:A
解説:
An automatic module name is derived from the name of the JAR file when it does not contain a module-info.class file. If the JAR file has an "Automatic-Module-Name" attribute in its main manifest, then its value is the module name. Otherwise, the module name is derived from the JAR file's name by removing any version numbers and converting it to lower case. Therefore, for a JAR named display-ascii-0.2.jar, the automatic module name would be display-ascii, following these rules.
質問 # 26
Given the code fragment:
What is the result?
- A. Range 1
Range 2
Range 3 - B. Range 1
Range 2
Range 3
Range 1
Not a valida rank - C. Range1
Note a valid rank. - D. Range 1
正解:B
解説:
Explanation
The code fragment is using the switch statement with the new Java 17 syntax. The switch statement checks the value of the variable rank and executes the corresponding case statement. In this case, the value of rank is 4, so the first case statement is executed, printing "Range1". The second and third case statements are also executed, printing "Range2" and "Range3". The default case statement is also executed, printing "Not a valid rank". References: Java Language Changes - Oracle Help Center
質問 # 27
Given:
What is the result?
- A. 101
101
1000 - B. 1001
100
1000 - C. 100
100
1000 - D. 1001
1001
1000
正解:B
解説:
The code fragment is using the bitwise operators & (AND), | (OR), and ^ (XOR) to perform operations on the binary representations of the integer values. The & operator returns a 1 in each bit position where both operands have a 1, the | operator returns a 1 in each bit position where either operand has a 1, and the ^ operator returns a 1 in each bit position where only one operand has a 1. The binary representations of the integer values are as follows:
1000 = 1111101000
100 = 1100100
101 = 1100101
The code fragment performs the following operations:
x = x ^ y; // x becomes 1111010101, which is 1001 in decimal
y = x ^ y; // y becomes 1100100, which is 100 in decimal
x = x ^ y; // x becomes 1100101, which is 101 in decimal
The code fragment then prints out the values of x, y, and z, which are 1001, 100, and 1000 respectively. Therefore, option D is correct.
質問 # 28
Given the code fragment:
Which code fragment invokes all callable objects in the workers set?
- A.

- B.

- C.

- D.

正解:C
解説:
Explanation
The code fragment in Option C invokes all callable objects in the workers set by using the ExecutorService's invokeAll() method. This method takes a collection of Callable objects and returns a list of Future objects representing the results of the tasks. The other options are incorrect because they either use the wrong method (invokeAny() or submit()) or have syntax errors (missing parentheses or semicolons). References: AbstractExecutorService (Java SE 17 & JDK 17) - Oracle
質問 # 29
Given the product class:
And the shop class:
What is the result?
- A. Cookie 2.99 2.99
- B. Cookie 0.0 0.0
- C. Cookie 0.0 2.99
- D. An exception is produced at runtime
- E. Cookie 3.99 2.99
- F. Compilation fails
正解:F
解説:
The code fragment will fail to compile because the readObject method in the Product class is missing the @Override annotation. The readObject method is a special method that is used to customize the deserialization process of an object. It must be declared as private, have no return type, and take a single parameter of type ObjectInputStream. It must also be annotated with @Override to indicate that it overrides the default behavior of the ObjectInputStream class. Without the @Override annotation, the compiler will treat the readObject method as a normal method and not as a deserialization hook. Therefore, the code fragment will produce a compilation error. Reference: Object Serialization - Oracle, [ObjectInputStream (Java SE 17 & JDK 17) - Oracle]
質問 # 30
Given:
Which statement is true while the program prints GC?
- A. Only one of the objects previously referenced by t1 is eligible for garbage collection.
- B. Only the object referenced by t2 is eligible for garbage collection.
- C. None of the objects are eligible for garbage collection.
- D. Both the objects previously referenced by t1 are eligible for garbage collection.
正解:D
質問 # 31
......
最新の検証済み1z1-829問題と解答で合格保証:https://www.passtest.jp/Oracle/1z1-829-shiken.html
1z1-829認証と実際の解答:https://drive.google.com/open?id=1HxpxoLKM2Upnu3Mi68vQ4BDZ6BQSD1Bp