Visit Official SkillCertPro Website :-
For a full set of 750+ questions. Go to
https://skillcertpro.com/product/ocp-java-se-17-developer-1z0-829-exam-questions/
SkillCertPro offers detailed explanations to each question which helps to understand the concepts better.
It is recommended to score above 85% in SkillCertPro exams before attempting a real exam.
SkillCertPro updates exam questions every 2 weeks.
You will get life time access and life time free updates
SkillCertPro assures 100% pass guarantee in first attempt.
Question 1:
In which order do the database resources need to be closed?
A. First Connection, then PreparedStatement, last ResultSet.
B. First Connection, then CallableStatement, last ResultSet.
C. First PreparedStatement, then ResultSet, last Connection.
D. First PreparedStatement, then Connection, last ResultSet.
E. First ResultSet, then PreparedStatement, last Connection.
F. First CallableStatement, then ResultSet, last Connection.
Answer: E
Explanation:
The ResultSet is closed first, followed by the PreparedStatement (or CallableStatement) and then the Connection, therefore Option E is the correct answer.
Question 2:
Which of the followings are valid Java identifiers?
A. $abc
B. _
C. 3abc
D. _test
E. test_
F. test$
Answer: A, D, E, F
Explanation:
Identifiers must begin with a letter, a currency symbol, or a _ symbol.
Currency symbols include dollar ($), yuan (¥), euro ( ), and so on.
Identifiers can include numbers but not start with them. A single underscore _ is not allowed as an identifier.
Therefore, Option A, Option D, Option E and Option F are correct answers.
Question 3:
What is the result of the following code snippet?
int x = 0;
while (x++ < 10) {
System.out.print(x);
x–;
}
A. 123456789
B. 12345678910
C. 1234567891011
D. The code does not compile.
E. The code compiles but an exception is thrown at runtime.
F. It hangs indefinitely.
Answer: F
Explanation:
The code prints 1 indefinitely because the value of x is first incremented by 1 and then decremented by 1, in each loop iteration.
There‘s no way out of the while loop, therefore Option F is the correct answer.
Question 4:
Which of the followings can fill in the blanks so that the code prints a number greater than or equal to 0? (Choose all that apply)
String s1 = “abc“;
String s2 = “def“;
String s3 = “xyz“;
System.out.println(________________);
What is the result?
A. s1.compareTo(s1)
B. s1.compareTo(s2)
C. s1.compareTo(s3)
D. s2.compareTo(s1)
E. s2.compareTo(s2)
F. s2.compareTo(s3)
Answer: A, D, E
Explanation:
The compareTo() method in the String class is used to compare two strings lexicographically.
The method returns 0 if the argument string is equal to this string, and a value greater than 0 if this string is lexicographically greater than the string argument.
Therefore, Option A, Option D and Option E are the correct answers.
Question 5:
Which of the following represent a valid way to establish a connection to a database? (Choose all that apply)
A. Driver.getConnection(url)
B. DriverManager.getConnection(url)
C. DriveManager.getConnection(url, username, password)
D. DriverManager.getConnection(url, username, password)
E. new Connection(url, username, password)
F. Connection.newConnection(url, username, password)
Answer: B, D
Explanation:
There are two main ways to retrieve a database Connection:
using DriverManager or DataSource. DataSource is not on the exam.
DriverManager has two methods which can be used to retrieve a Connection:
DriverManager.getConnection(String url)
DriverManager.getConnection(String url,String user, String password)
Notice that the class is called DriverManager, not DriveManager.
Therefore, the only correct answers are Option B and Option D.
For a full set of 750+ questions. Go to
https://skillcertpro.com/product/ocp-java-se-17-developer-1z0-829-exam-questions/
SkillCertPro offers detailed explanations to each question which helps to understand the concepts better.
It is recommended to score above 85% in SkillCertPro exams before attempting a real exam.
SkillCertPro updates exam questions every 2 weeks.
You will get life time access and life time free updates
SkillCertPro assures 100% pass guarantee in first attempt.
Question 6:
What is the output of the following Java application?
10: class Application {
11: public static void main(String[] args) {
12: float x = 5.5;
13: double y = 6.5;
14: var z = x + y;
15: System.out.println(z);
16: }
17:v}
A. It prints 12.
B. It prints 12.0.
C. The code does not compile due to an error on Line 12.
D. The code does not compile due to an error on Line 13.
E. The code does not compile due to an error on Line 14.
F. The code compiles but an exception is thrown at runtime.
Answer: C
Explanation:
Floating-point literals are assumed to be of type double unless post-fixed with an f or with an F.
If the value of x would have been properly set to 5.5f or 5.5F, then x would have been promoted to a double when performing the addition, and the result would be a double value, therefore Option C is the correct answer.
Question 7:
What is the output of the following code snippet?
int value = 2;
switch (value) {
case 1: case 2: System.out.print(“a“);
case 3:
System.out.print(“b“);
default:
break;
}
A. a
B. aab
C. ab
D. The code does not compile.
E. The code compiles but an exception is thrown at runtime.
F.None of the above.
Answer: C
Explanation:
Not every case in a switch statement needs to contain a break statement.
If no break statements appear, the flow of control will fall through to subsequent cases until a break statement is reached.
Therefore, Option C is the correct answer.
Question 8:
Which of the following statements are true? (Choose all that apply)
A. All Set implementations and List implementations have in common that they do allow duplicates.
B. HashSet stores its elements in a hash table, therefore the set collection is always in sorted order.
C. Set.of() is used to create an immutable set.
D. Queue and Deque interfaces do not allow duplicate elements.
E. Map interface doesn‘t extend Collection interface.
F. TreeSet do allow null values.
Answer: C, E
Question 9:
What is the result of the following code snippet?
Path mypath = Path.of(“/a/b/“);
System.out.println(mypath.resolve(“/c/d“) + “-“ + mypath.resolve(“e/f“));
A) /a/b/c/d-/a/b/e/f
B) /a/b/c/d-/e/f
C) /c/d-/a/b/e/f
D) /c/d-/e/f
E) /a/b-/a/b
F) None of the above
Answer: C
Explanation:
If an absolute path is provided as input to the resolve() method, then that value is the one returned, otherwise resolve() method is performing concatenation, therefore Option C is the correct answer.
Question 10:
What is the result of the following program?
class Application {
public static void main(String[] args) {
int x = 1;
while (x++ < 9) {
System.out.print(x++);
}
}
}
A) 12345678 B) 23456789
C) 3579 D) 2468
E) 246810 F) 357911
Answer: D
Explanation:
Since the post-increment operator is used which evaluates to the original value of the variable before increase, the result is 2468 which makes Option D the correct answer.
For a full set of 750+ questions. Go to
https://skillcertpro.com/product/ocp-java-se-17-developer-1z0-829-exam-questions/
SkillCertPro offers detailed explanations to each question which helps to understand the concepts better.
It is recommended to score above 85% in SkillCertPro exams before attempting a real exam.
SkillCertPro updates exam questions every 2 weeks.
You will get life time access and life time free updates
SkillCertPro assures 100% pass guarantee in first attempt.