Java Certification (1Z0-829) Topic-wise Tests Part-1 [2025]
![Java Certification (1Z0-829) Topic-wise Tests Part-1 [2025]](https://thumbs.comidoc.net/750/4641832_0406_3.jpg)
Why take this course?
Based on the outline provided for the practice test examining the Java SE 17 OCA (Oracle Certified Associate) objectives, here are some example questions that follow the pattern and complexity of the actual exam. Remember, these are designed to be similar in nature and to help you prepare, but they are not official exam questions.
Test 1: Handling date, time, text, numeric and boolean values
-
Given the following code snippet:
int number = 9 / 2; boolean condition = (number != 0);
What will be the output of
System.out.println(condition);
?- A) True
- B) False
- C) Compilation Error
- D) Runtime Exception
-
Which of the following types can represent an object that contains a collection of other objects?
- A) Integer
- B) String
- C) List
- D) Map<Integer, List>
-
In Java, which method from the
Math
class would you use to calculate the square root of 49?- A) Math.sqrt(49)
- B) Math.pow(49, 0.5)
- C) Math.cbrt(49)
- D) None of the above
Test 2: Controlling Program Flow and Handling Exceptions
-
Which loop structure allows for breaking out of the loop based on a condition?
- A)
for
loop - B)
do-while
loop - C)
while
loop - D) All of the above
- A)
-
Consider the following exception handling block:
try { int result = 10 / 0; } catch (ArithmeticException e) { System.out.println("Cannot divide by zero!"); }
What will be the output?
- A) "Cannot divide by zero!"
- B) Compilation Error
- C) Runtime Exception
- D) None of the above
-
Which of the following is not a valid way to create an infinite loop?
- A)
while (true) {}
- B)
for (;;) {}
- C)
do {} while (false);
- D)
while (condition = true) {}
- A)
Test 3: Working with Arrays and Collections (Part-1)
-
Which of the following arrays can store primitive
int
values?- A)
int[] numbers = new int[5]{10, 20, 30};
- B)
Integer[] numbers = new Integer[]{10, 20, 30};
- C)
List<Integer> numbers = new ArrayList<>(Arrays.asList(10, 20, 30));
- D) All of the above
- A)
-
If you have a
List<String>
, how can you add a new element to the end of the list?- A)
list.add("new string");
- B)
list[list.size()] = "new string";
- C)
list.push("new string");
- D) None of the above
- A)
-
Which collection interface allows for no duplicate elements?
- A)
List<T>
- B)
Set<T>
- C)
Map<K, V>
- D)
Queue<T>
- A)
Test 4: Working with Arrays and Collections (Part-2)
-
Which of the following methods can you use to reverse a list?
- A)
list.reverse();
- B)
Collections.reverse(list);
- C)
List<T> reversedList = new ArrayList<>(Arrays.asList(array).reverse());
- D) All of the above
- A)
-
Consider the following code snippet:
Map<String, Integer> fruitBasket = new HashMap<>(); fruitBasket.put("Apple", 5); fruitBasket.put("Orange", 3);
How many oranges are in the
fruitBasket
?- A) 5
- B) 3
- C) The number of oranges is not determinable from the given code
- D) Compilation Error
-
Which of the following is a functional interface that can take no parameters and return a boolean?
- A)
Runnable
- B)
Callable
- C)
Predicate<T>
- D)
Consumer<T>
- A)
These questions cover a range of topics within the scope of the OCA exam. They are designed to test your understanding of basic Java programming concepts, exception handling, and working with arrays and collections. Remember to review the official documentation for any updates or changes that may have been made to the Java language since the knowledge cutoff date for the exam. Good luck with your preparation!
Loading charts...