Handsome Savings - Limited Time Offer 30% OFF - Ends In 0d 0h 0m 0s Coupon code: 50OFF
Welcome to QA4Exam
Logo

- Trusted Worldwide Questions & Answers

Oracle 1Z0-829 Exam Actual Questions

The questions for 1Z0-829 were last updated on Oct 3, 2024.
  • Viewing page 1 out of 10 pages.
  • Viewing questions 1-5 out of 50 questions
Unlock Access to All 50 Questions & Answers
Question No. 1

Given:

Which statement is true while the program prints GC?

Show Answer Hide Answer
Correct Answer: B

Question No. 2

Given the code fragment:

What is the result?

Show Answer Hide Answer
Correct Answer: D

The answer is E because the code fragment creates a new Pet object with the name ''Dog'' and assigns it to the variable p. Then, it assigns p to p1. Next, it changes the name of p1 to ''Cat''. Then, it assigns p1 to p. Finally, it sets p to null and prints the name of p and p1. The output will be ''Cat'' and ''null'' because p is set to null and p1 still points to the Pet object with the name ''Cat''.


Question No. 3

Given:

Which two modifications enable the code to print Open Close?

A)

B)

C)

D)

E)

Show Answer Hide Answer
Correct Answer: 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''.


Question No. 4

Given:

Which statement is true?

Show Answer Hide Answer
Correct Answer: B

The answer is B because the code fragment contains a syntax error that prevents it from compiling. The code fragment tries to catch a StockException in line 10, but the catch block does not have a parameter of type StockException. The catch block should have a parameter of type StockException, such as:

catch (StockException e) { // handle the exception }

This is required by the Java syntax for the catch clause, which must have a parameter that is a subclass of Throwable. Without a parameter, the catch block is invalid and causes a compilation error.

Option A is incorrect because the program does not throw a StockException, as it does not compile.

Option C is incorrect because the program does not throw an OutofStockException, as it does not compile.

Option D is incorrect because the program does not throw a ClassCastException, as it does not compile.Reference:

Oracle Certified Professional: Java SE 17 Developer

Java SE 17 Developer

OCP Oracle Certified Professional Java SE 17 Developer Study Guide

The try-with-resources Statement (The Java Tutorials > Essential Classes > Exceptions)

The catch Blocks (The Java Tutorials > Essential Classes > Exceptions)


Question No. 5

Which statement is true about modules?

Show Answer Hide Answer
Correct Answer: C

A module path is a sequence of directories that contain modules or JAR files. A named module is a module that has a name and a module descriptor (module-info.class) that declares its dependencies and exports. An automatic module is a module that does not have a module descriptor, but is derived from the name and contents of a JAR file. Both named and automatic modules can be placed on the module path, and they can be resolved by the Java runtime. An unnamed module is a special module that contains all the classes that are not in any other module, such as those on the class path. An unnamed module is not on the module path, but it can read all other modules.


Product Image

Unlock All Questions for Oracle 1Z0-829 Exam

Full Exam Access, Actual Exam Questions, Validated Answers, Anytime Anywhere, No Download Limits, No Practice Limits

Get All 50 Questions & Answers