[2024年06月05日] トップクラスの1z1-829練習試験問題
実際問題を使って1z1-829無料問題集サンプル問題と練習テストエンジン
質問 # 19
Given the product class:
And the shop class:
What is the result?
- A. Cookie 0.0 2.99
- B. Cookie 2.99 2.99
- C. Compilation fails
- D. An exception is produced at runtime
- E. Cookie 0.0 0.0
- F. Cookie 3.99 2.99
正解:C
解説:
Explanation
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. References: Object Serialization - Oracle, [ObjectInputStream (Java SE 17 & JDK 17) - Oracle]
質問 # 20
Given:
What is the result?
- A. runsruns
- B. runsflips
- C. flipsruns
- D. flipsflips
- E. Compilation fails
正解:E
解説:
The code fragment will fail to compile because the play method in the Dog class is declared as private, which means that it cannot be accessed from outside the class. The main method is trying to call the play method on a Dog object, which is not allowed. Therefore, the code fragment will produce a compilation error.
質問 # 21
Which two code fragments compile?
- A.

- B.

- C.

- D.

- E.

正解:A、E
解説:
Explanation
The two code fragments that compile are B and E. These are the only ones that use the correct syntax for declaring and initializing a var variable. The var keyword is a reserved type name that allows the compiler to infer the type of the variable based on the initializer expression. However, the var variable must have an initializer, and the initializer must not be null or a lambda expression. Therefore, option A is invalid because it does not have an initializer, option C is invalid because it has a null initializer, and option D is invalid because it has a lambda expression as an initializer. Option B is valid because it has a String initializer, and option E is valid because it has an int initializer.
https://docs.oracle.com/en/java/javase/17/language/local-variable-type-inference.html
質問 # 22
Which two code fragments compile?
- A.

- B.

- C.

- D.

- E.

正解:B、E
解説:
The two code fragments that compile are B and E. These are the only ones that use the correct syntax for declaring and initializing a var variable. The var keyword is a reserved type name that allows the compiler to infer the type of the variable based on the initializer expression. However, the var variable must have an initializer, and the initializer must not be null or a lambda expression. Therefore, option A is invalid because it does not have an initializer, option C is invalid because it has a null initializer, and option D is invalid because it has a lambda expression as an initializer. Option B is valid because it has a String initializer, and option E is valid because it has an int initializer.
https://docs.oracle.com/en/java/javase/17/language/local-variable-type-inference.html
質問 # 23
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-0
- B. Display-ascii
- C. Display.ascii
- D. Display-ascii-0.2
正解:B
解説:
Explanation
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.
質問 # 24
Given:
What is the result?
- A. Mb
- B. Mb
- C. Mb
MC - D. mA
- E. MA
正解:D
解説:
The code snippet is an example of Java SE 17 code. The code is checking if the object is an instance of class C and if it is, it will print "mC". If it is not an instance of class C, it will print "mA". In this case, the object is not an instance of class C, so the output will be "mA". Reference: Pattern Matching for instanceof - Oracle Help Center
質問 # 25
Given the code fragment:
What is the result?
- A. Logged out at: 2021-01-12T21:58:00z
- B. Logged out at: 2021-0112T21:58:19.880z
- C. Can't logout
- D. A compilation error occurs at Line n1.
正解:A
解説:
Explanation
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. 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/17/docs/api/java.base/java/time/Instant.html#truncatedTo(java.time.tempora
質問 # 26
Given the code fragments:
Which is true?
- A. The program prints an exception
- B. The program prints t1 : 1: t2 : 1: t1 : 1 : t2 : 1 : indefinitely
- C. The program prints t1 : 1 : t2: 1 : t1 : 2 : t2: 2:
- D. The program prints t1 : 1: t2 : 1: t1 : t2 : 2 : in random order.
正解:C
解説:
The code creates two threads, t1 and t2, and starts them. The threads will print their names and the value of the Atomic Integer object, x, which is initially set to 1. The threads will then increment the value of x and print their names and the new value of x. Since the threads are started at the same time, the output will be in random order. However, the final output will always be t1 : 1 : t2: 1 : t1 : 2 : t2: 2: Reference: AtomicInteger (Java SE 17 & JDK 17) - Oracle
質問 # 27
Given:
Which two should the module-info file include for it to represent the service provider interface?
- A. Requires cm.transport.vehicle,cars:
- B. Exports com.transport.vehicle.cars;
- C. Requires cm.transport.vehicle,cars:
- D. Exports com.transport.vehicle;
- E. Provides.com.transport.vehicle.cars.Car with com.transport.vehicle.cars. impt, CatImpI;
- F. Provides.com.transport.vehicle.cars.Car impl,CarImp1 to com.transport.vehicle.cars. Cars
- G. exports com.transport.vehicle.cars.Car;
正解:E、G
解説:
Explanation
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
質問 # 28
Given:
What is the result?
- A. 1 Snowy
- B. 1 RAINY
- C. Compilation fails
- D. 0 CLOUDY
- E. 0 Snowy
正解:E
解説:
The code is defining an enum class called Forecast with three values: SUNNY, CLOUDY, and RAINY. The toString() method is overridden to always return "SNOWY". In the main method, the ordinal value of SUNNY is printed, which is 0, followed by the value of CLOUDY converted to uppercase, which is "CLOUDY". However, since the toString() method of Forecast returns "SNOWY" regardless of the actual value, the output will be "0 SNOWY". Reference: Enum (Java SE 17 & JDK 17), Enum.EnumDesc (Java SE 17 & JDK 17)
質問 # 29
Given the code fragment:
What is the result?
- A. Range 1
Range 2
Range 3 - B. Range 1
- C. Range1
Note a valid rank. - D. Range 1
Range 2
Range 3
Range 1
Not a valida rank
正解:D
解説:
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". Reference: Java Language Changes - Oracle Help Center
質問 # 30
Daylight Saving Time (DST) is the practice of advancing clocks at the start of spring by one hour and adjusting them backward by one hour in autumn.
Considering that in 2021, DST in Chicago (Illinois) ended on November 7th at 2 AM, and given the fragment:
What is the output?
- A. true
true - B. true
false - C. false
true - D. False
false
正解:B
解説:
Explanation
The answer is A because the code fragment uses the ZoneId and ZonedDateTime classes to create two date-time objects with the same local date-time but different zone offsets. The ZoneId class represents a time-zone ID, such as America/Chicago, and the ZonedDateTime class represents a date-time with a time-zone in the ISO-8601 calendar system. The code fragment creates two ZonedDateTime objects with the same local date-time of 2021-11-07T01:30, but different zone IDs of America/Chicago and UTC. The code fragment then compares the two objects using the equals and isEqual methods.
The equals method compares the state of two objects for equality. In this case, it compares the local date-time, zone offset, and zone ID of the two ZonedDateTime objects. Since the zone offsets and zone IDs are different, the equals method returns false.
The isEqual method compares the instant of two temporal objects for equality. In this case, it compares the instant of the two ZonedDateTime objects, which is derived from the local date-time and zone offset. Since DST in Chicago ended on November 7th at 2 AM in 2021, the local date-time of 2021-11-07T01:30 in America/Chicago corresponds to the same instant as 2021-11-07T06:30 in UTC. Therefore, the isEqual method returns true.
Hence, the output is true false. References:
Oracle Certified Professional: Java SE 17 Developer
Java SE 17 Developer
OCP Oracle Certified Professional Java SE 17 Developer Study Guide
ZoneId (Java Platform SE 8 )
ZonedDateTime (Java Platform SE 8 )
Time Zone & Clock Changes in Chicago, Illinois, USA
Daylight Saving Time Changes 2023 in Chicago, USA
質問 # 31
Which statement is true?
- A. thread in waiting state consumes CPU cycles.
- B. IllegalStateException is thrown if a thread in waiting state is moved back to runnable.
- C. After the timed wait expires, the waited thread moves to the terminated state.
- D. A thread in waiting state must handle InterrupedException.
正解:D
解説:
Explanation
A thread in waiting state is waiting for another thread to perform a particular action, such as calling notify() or notifyAll() on a shared object, or terminating a joined thread. A thread in waiting state can be interrupted by another thread, which will cause the waiting thread to throw an InterruptedException and return to the runnable state. Therefore, a thread in waiting state must handle InterruptedException, either by catching it or declaring it in the throws clause. References: Thread.State (Java SE 17 & JDK 17), [Thread (Java SE 17 & JDK 17)]
質問 # 32
Given:
What is the result?
- A. The program throws a MissingResourceException.
- B. User name (EN - US)
- C. User name (EN)
- D. UserName
- E. User name (US)
正解:A
解説:
The answer is B because the code fragment contains a logical error that causes a MissingResourceException at runtime. The code fragment tries to load a resource bundle with the base name "Captions.properties" and the locale "en_US". However, there is no such resource bundle available in the classpath. The available resource bundles are:
Captions.properties
Captions_en.properties
Captions_US.properties
Captions_en_US.properties
The ResourceBundle class follows a fallback mechanism to find the best matching resource bundle for a given locale. It first tries to find the resource bundle with the exact locale, then it tries to find the resource bundle with the same language and script, then it tries to find the resource bundle with the same language, and finally it tries to find the default resource bundle with no locale. If none of these resource bundles are found, it throws a MissingResourceException.
In this case, the code fragment is looking for a resource bundle with the base name "Captions.properties" and the locale "en_US". The ResourceBundle class will try to find the following resource bundles in order:
Captions.properties_en_US
Captions.properties_en
Captions.properties
However, none of these resource bundles exist in the classpath. Therefore, the ResourceBundle class will throw a MissingResourceException.
To fix this error, the code fragment should use the correct base name of the resource bundle family, which is "Captions" without the ".properties" extension. For example:
ResourceBundle captions = ResourceBundle.getBundle("Captions", currentLocale); This will load the appropriate resource bundle for the current locale, which is "Captions_en_US.properties" in this case. Reference:
Oracle Certified Professional: Java SE 17 Developer
Java SE 17 Developer
OCP Oracle Certified Professional Java SE 17 Developer Study Guide
ResourceBundle (Java Platform SE 8 )
About the ResourceBundle Class (The Java™ Tutorials > Internationalization)
質問 # 33
Given:
- A. Compilation fails
- B. A NumberFormatException is thrown
- C. Hello
- D. there
正解:A
解説:
Explanation
The code fragment will fail to compile because the parseInt method of the Integer class is a static method, which means that it can be invoked without creating an object of the class. However, the code is trying to invoke the parseInt method on an object of type Integer, which is not allowed. The correct way to invoke the parseInt method is by using the class name, such as Integer.parseInt (s). Therefore, the code fragment will produce a compilation error. References: Integer (Java SE 17 & JDK 17) - Oracle
質問 # 34
Given:
Which two method invocation execute?
- A. new MyC() .m2 ();
- B. Ifnce.m3 ();
- C. IFace myclassobj = new Myc ();
myclassObj.m3 (); - D. IFace.m2();
- E. IFace .,4():
- F. iFace mucloassObj = new Myc ();
myClassObj.m4();
正解:A、E
解説:
The code given is an interface and a class that implements the interface. The interface has three methods, m1(), m2(), and m3(). The class has one method, m1(). The only two method invocations that will execute are D and E. D is a call to the m2() method in the class, and E is a call to the m3() method in the interface. Reference: https://education.oracle.com/products/trackp_OCPJSE17, 3, 4, 5
質問 # 35
Given the code fragment:
What is the result?
- A. Range 1
Range 2
Range 3 - B. Range 1
- C. Range1
Note a valid rank. - D. Range 1
Range 2
Range 3
Range 1
Not a valida rank
正解:D
解説:
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
質問 # 36
Given the content of the in. tart file:
23456789
and the code fragment:
What is the content of the out .txt file?
- A. 01234567801234
- B. 0123456789
- C. 012345678
- D. 01234567
- E. 012345678901234
- F. 0123456789234567
正解:B
解説:
The answer is D because the code fragment reads the content of the in.txt file and writes it to the out.txt file. The content of the in.txt file is "23456789". The code fragment uses a char array buffer of size 8 to read the content of the in.txt file. The while loop reads the content of the in.txt file and writes it to the out.txt file until the end of the file is reached. Therefore, the content of the out.txt file will be "0123456789".
質問 # 37
Given:
Which two method invocation execute?
- A. new MyC() .m2 ();
- B. Ifnce.m3 ();
- C. iFace mucloassObj = new Myc (); myClassObj.m4();
- D. IFace.m2();
- E. IFace .,4():
- F. IFace myclassobj = new Myc (); myclassObj.m3 ();
正解:A、E
解説:
Explanation
The code given is an interface and a class that implements the interface. The interface has three methods, m1(), m2(), and m3(). The class has one method, m1(). The only two method invocations that will execute are D and E.
D is a call to the m2() method in the class, and E is a call to the m3() method in the interface. References:
https://education.oracle.com/products/trackp_OCPJSE17, 3, 4, 5
質問 # 38
Given:
What is the result?
- A. Compilation fails
- B. wTableChair TableChair
- C. Wtablechair tableChair
- D. Tablechair Tablechair
- E. A RuntimeException is thrown
正解:A
解説:
Explanation
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.
質問 # 39
Given the code fragment:
Which action sorts the book list?
- A. At Line n1, convert type to mutable array type.
- B. At Line n2, replace books,sort() with books.stream().sort(0.
- C. At line n1, convert books type to mutable ArrayList type.
- D. At Line n2, replace compareTo () with compare ().
正解:D
解説:
The code fragment is trying to sort a list of books using the Collections.sort() method. The correct answer is D, because the compareTo() method is not the correct way to compare two objects in a Comparator. The compare() method is the correct way to compare two objects in a Comparator and return an int value that indicates their order1. The compareTo() method is used to implement the Comparable interface, which defines the natural order of objects of a class2. The other options are incorrect because they either do not change the type of the list, which is already mutable, or they do not use the correct syntax for sorting a stream, which requires a terminal operation such as collect()3. Reference: Comparator (Java SE 17 & JDK 17), Comparable (Java SE 17 & JDK 17), Stream (Java SE 17 & JDK 17)
質問 # 40
Given the code fragment:
What is the result?
- A. False true true optional (Newyear)
- B. 0110
- C. True true false NewYear
- D. 010 optional (Newyear)
正解:A
解説:
Explanation
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)
質問 # 41
Given:
What is the result?
- A. Software Game Chess 0
- B. Software Game Software Game chess 0
- C. Software Game read error
- D. Software Game Software Game Chese 2
- E. Software game write error
- F. Software Game Chess 2
正解:D
解説:
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". Reference:
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
質問 # 42
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 2 with static string name;
- D. Replace 3 with private static void display () {
正解: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
質問 # 43
......
合格させるOracle 1z1-829試験問題でテスト復刻エンジンとPDF:https://www.passtest.jp/Oracle/1z1-829-shiken.html
2024年最新の実際に出ると確認されたOracle 1z1-829無料試験問題:https://drive.google.com/open?id=10tgde3-eUP2er9BpPxdN2Jonaad8ghkJ