Courseiva

1Z0-829 · domain

Controlling Program Flow

Practise RAM questions covering identification, installation, speeds, dual-channel, and troubleshooting for the 1Z0-829 exam.

76 questions23 easy31 medium22 hard

Focused practice

Practice Controlling Program Flow questions

Scored sessions drawing only from this domain — pick a length below.

Start 20-question practice test →

What this domain covers

What to know about Controlling Program Flow

RAM tests your ability to identify, install, and troubleshoot memory types, speeds, and configurations for PCs.

Identifying DDR3 vs DDR4 vs DDR5 physical and electrical differences

Matching RAM speed (MHz) to motherboard and CPU support

Calculating total memory capacity from module size and slots

Troubleshooting common RAM errors like beep codes and blue screens

Why learners struggle

Why Controlling Program Flow questions are commonly missed

RAM questions are commonly missed because learners confuse physical form factors (DIMM vs SO-DIMM) and fail to distinguish between memory speed (MHz) and latency (CL).

  • ·DIMM vs SO-DIMM — desktop vs laptop form factor confusion
  • ·DDR3 vs DDR4 vs DDR5 — notch position and voltage differences
  • ·MHz vs CL — speed vs latency trade-offs in performance
  • ·Single-channel vs dual-channel — bandwidth impact misconception
  • ·ECC vs non-ECC — error correction support in servers vs desktops
  • ·32-bit vs 64-bit — maximum addressable RAM limit

Watch out for

Common Controlling Program Flow exam traps

  • Confusing DDR3 and DDR4 notch positions and voltage requirements
  • Assuming dual-channel requires identical size modules only
  • Mixing ECC and non-ECC RAM in a single system
  • Forgetting that 32-bit OS limits usable RAM to 4 GB

Question index

All Controlling Program Flow questions (76)

Click any question to see the full explanation, or start a practice session above.

1

Given: for(int i=0; i<3; i++) { for(int j=0; j<3; j++) { if(i==1 && j==1) break; } } What is the value of i after the outer loop completes?

Easy
2

Given nested loops with labels, which statement correctly breaks out of the outer loop?

Medium
3

Given the following Java code: ```java for (int i = 0; i <= 2; i++) { for (int j = i; j <= i+2; j++) { if (j <= 3) { System.out.print(j + " "); } } } ``` What is the output?

Hard
4

Which of the following correctly uses a switch expression with multiple constants per case? ```java int day = 2; String result = switch (day) { case 1, 2, 3 -> "Weekday"; case 6, 7 -> "Weekend"; default -> "Invalid"; }; ``` What is the value of result?

Easy
5

Match each Java module directive to its description.

Medium
6

A developer is implementing a method that processes a collection of objects. The objects are instances of various classes that implement a common interface. The developer wants to use a switch expression to perform different actions based on the runtime type of each object. Which approach is correct?

Medium
7

Which two statements about the break statement are true?

Medium
8

Given the following switch expression with colon syntax, what is the result when code equals 2? int val = switch(code) { case 1: yield 10; case 2: yield 20; default: yield 30; };

Hard
9

Consider the following do-while loop: ```java int x = 10; do { x--; } while (x < 10); System.out.println(x); ``` What is printed?

Medium
10

What is the output?

Easy
11

Order the steps to properly handle resources using try-with-resources in Java.

Medium
12

Given: int x=1; switch(x) { case 1: System.out.print("A"); case 2: System.out.print("B"); break; default: System.out.print("C"); } What is printed?

Medium
13

Which two of the following statements are true about the continue statement in a loop?

Easy
14

Refer to the exhibit. What is the output when the program is executed?

Medium
15

What is the output? ```java int x = 10; do { System.out.print(x); } while (x-- > 10); ```

Medium
16

Which TWO correctly describe the behavior of the following code? ```java int x = 10; switch (x) { case 10: System.out.print("ten "); default: System.out.print("default "); case 20: System.out.print("twenty "); } ```

Medium
17

What is the likely cause of this compilation error? ```java String day = "Monday"; int dayNum = switch (day) { case 1 -> 1; case 2 -> 2; default -> 0; }; System.out.println(dayNum); ```

Easy
18

Given: int a=5, b=10; String result = (a > b) ? "greater" : (a < b) ? "less" : "equal"; What is result?

Medium
19

Which THREE statements are true about loops in Java?

Hard
20

A developer writes a method that uses a for loop to iterate over a list of strings and remove elements that match a specific pattern using the list's remove(int index) method. The developer uses an index variable that increments normally. However, after running the method, some elements that should have been removed are still present, and some elements are skipped. The list initially contains [A, B, C, D, E] and the developer expects to remove B and D. After the loop, the list is [A, C, E] as expected? Actually, the developer observes that after the loop, the list contains [A, C, D, E] (D was not removed). What is the most likely cause?

Medium
21

What is the output?

Hard
22

Which statement is correct about the following switch expression? String result = switch(day) { case MONDAY, TUESDAY -> "weekday"; case WEDNESDAY -> "midweek"; default -> "other"; };

Medium
23

Given: for(int i=0; i<10; i++) { if(i%2==0) continue; System.out.print(i+" "); } What is the output?

Easy
24

Refer to the exhibit. The exhibit shows a code snippet. What is the output when the variable day is set to Day.WEDNESDAY?

Medium
25

Given the following code fragment: ```java int x = 0; for (int i = 0; i < 4; i++) { x++; } System.out.println(x); ``` What is the result?

Medium
26

A developer has a method that contains a try-catch-finally block inside a while loop. The try block throws a checked exception that is caught by the catch block. The catch block throws a new runtime exception. What is the behavior?

Hard
27

Which two statements about the enhanced for-each loop in Java are true? (Choose two.)

Hard
28

A developer is designing a loop to iterate through an array of integers and stop processing when the value -1 is encountered. Which loop construct should be used?

Easy
29

What is the output of the following code? int i=5; do { System.out.print(i); i--; } while(i>0);

Medium
30

Given an enum Direction { NORTH, SOUTH, EAST, WEST } and a variable d of type Direction, which code snippet correctly uses a switch expression to map each direction to an abbreviation (N, S, E, W) without using a default branch?

Medium
31

Which three of the following statements about the switch expression in Java 17 are correct?

Hard
32

Which THREE statements are true about the enhanced for loop in Java?

Hard
33

Match each I/O stream class to its description.

Medium
34

Given: int x=0; do { x++; } while(x<5); How many times does the loop body execute?

Easy
35

A Java application processes a list of orders. Each order has a status: NEW, PROCESSING, SHIPPED, or DELIVERED. The code must print a message based on the status: - If NEW: "Order received" - If PROCESSING: "Order in progress" - If SHIPPED: "Order shipped" - If DELIVERED: "Order delivered" - For any other status: "Unknown status" The developer writes the following code using a switch expression: String message = switch (status) { case NEW -> "Order received"; case PROCESSING -> "Order in progress"; case SHIPPED -> "Order shipped"; case DELIVERED -> "Order delivered"; default -> "Unknown status"; }; System.out.println(message); What is the correct course of action to ensure the code compiles and runs correctly?

Easy
36

A junior developer writes a method that uses a switch statement to handle different types of user input. The input is an integer representing an operation code. The developer uses a traditional switch statement with break statements. However, when operation code 2 is entered, the program also executes the code for operation 3. What is the most likely cause?

Easy
37

A developer writes a method that processes a grade and returns a message using a switch expression. The code is: ```java public static String getMessage(int grade) { return switch (grade) { case 90, 80 -> "Excellent"; case 70, 60 -> "Good"; case 50 -> "Pass"; default -> "Fail"; }; } ``` Which statement is correct about this code?

Medium
38

Which two statements about the do-while loop are true?

Easy
39

A method contains a try-with-resources statement that uses two resources: a FileInputStream and a BufferedInputStream. The FileInputStream constructor throws a FileNotFoundException. Which statement about resource closing is true?

Hard
40

Order the steps to handle checked exceptions in a method that throws IOException.

Medium
41

Which TWO of the following are valid forms of the switch statement/expression in Java?

Easy
42

A resource is declared in a try-with-resources statement. The try block throws an exception. The close method throws a different exception. What exception is thrown by the try-with-resources statement?

Hard
43

A developer wrote a method that uses a for-each loop to iterate over a list of strings and remove elements that match a certain condition. However, the method throws a ConcurrentModificationException at runtime. What is the most likely cause?

Hard
44

Which loop construct guarantees that the body executes at least once?

Easy
45

Given the following code: ```java outer: for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { if (i == 1) { continue outer; } System.out.print(i + " " + j + " "); } } ``` What is the output?

Hard
46

Given the code snippet: int x = 10; if (x > 5) { System.out.print("A"); } else if (x > 7) { System.out.print("B"); } else { System.out.print("C"); } What is the output?

Easy
47

Which TWO statements about the break and continue statements in Java are correct?

Easy
48

A financial application processes a daily batch of 10 million transactions. Each transaction is an object with fields: id, amount, and status (an enum: PENDING, APPROVED, REJECTED). The requirement is to find the first APPROVED transaction with amount greater than 1000. The current implementation uses a while loop with a nested if-else structure that checks each transaction sequentially. The loop also logs each transaction status, which involves a moderately expensive file write operation. Performance analysis shows the method is a bottleneck, often taking over 12 seconds. The development team is considering refactoring. Which course of action will most effectively reduce execution time while maintaining the requirement?

Hard
49

A method uses an enhanced for loop to iterate over a list of strings and prints each string. The code is: ```java List<String> list = List.of("A", "B", "C"); for (String s : list) { if (s.equals("B")) { break; } System.out.print(s); } ``` What is the result?

Medium
50

Refer to the exhibit. The exhibit shows a stack trace from a Java application. Which line in the code caused the NullPointerException?

Easy
51

You are developing a high-frequency trading application that processes a stream of market data ticks. Each tick is represented by a Tick object with fields: long timestamp, String symbol, double price, int volume. Ticks arrive in real-time and must be processed in order. A bug is reported: the application occasionally processes a tick out of order, causing incorrect trade decisions. The processing logic uses a while loop to read from a blocking queue and process each tick. The code is: BlockingQueue<Tick> queue = new LinkedBlockingQueue<>(); while (true) { Tick tick = queue.take(); process(tick); } After investigation, you find that the queue is fed by multiple producer threads that sometimes reorder ticks due to network delays. Which course of action best ensures ticks are processed in the correct chronological order without sacrificing throughput?

Hard
52

Which TWO statements are true about the switch statement in Java?

Medium
53

A developer is implementing a batch processing application that reads records from a list and processes them. The method uses a for loop with an index variable. Inside the loop, if a record is null, the developer wants to skip that iteration and continue with the next index. The developer writes: for (int i = 0; i < records.size(); i++) { if (records.get(i) == null) continue; process(records.get(i)); updateCounter(); } However, the counter is not updated correctly. The developer expects the counter to reflect the number of processed (non-null) records. What is the problem?

Medium
54

What is the output?

Easy
55

What is the output of the following code snippet? int x = 5; if(x > 0) { System.out.print('A'); } else if(x > 2) { System.out.print('B'); } else { System.out.print('C'); }

Easy
56

Given: outer: for(int i=0; i<3; i++) { for(int j=0; j<3; j++) { if(j==1) continue outer; } } How many times does the innermost loop body execute?

Hard
57

A developer writes code to iterate over a list of strings and print each element. The code uses an enhanced for loop. Which statement is true about the enhanced for loop?

Medium
58

Given: int i=0; outer: while(i<3) { for(int j=0; j<3; j++) { if(j==1) break outer; } i++; } What is the value of i after the outer loop?

Hard
59

In a large enterprise application, a concurrent caching system is implemented using a ConcurrentHashMap that is accessed by multiple threads concurrently. The cache performs atomic operations on individual keys, but some operations require updates on multiple keys. To ensure consistency, the code acquires intrinsic locks on the keys using synchronized blocks. Over time, the system has been experiencing intermittent deadlocks. During post-mortem analysis, it was found that thread A holds a lock on key X and is waiting for key Y, while thread B holds a lock on key Y and is waiting for key X. The development team needs to redesign the locking strategy to eliminate these deadlocks while maintaining high throughput and minimizing code changes. They consider the following proposals: replacing ConcurrentHashMap with Collections.synchronizedMap, using a single ReentrantLock for all cache operations, always acquiring locks on keys in a consistent global order, or using a Lock with tryLock and a timeout and releasing all locks if timeout expires. Based on best practices in concurrent programming and considering the requirements to avoid deadlocks and maintain performance, which approach should they choose?

Hard
60

Given the following code snippet: ```java outer: for (int i = 0; i < 3; i++) { for (int j = 0; j < 3; j++) { if (i == 1 && j == 1) { break outer; } System.out.print(i + "-" + j + " "); } } ``` What is the output?

Hard
61

A Java developer is writing a batch processing application that reads records from a database and processes them. The processing must continue even if some records cause exceptions (e.g., data conversion errors). However, the application must log each failed record and its error, then continue with the next record. The developer uses a for loop to iterate over a list of records. Inside the loop, a try-catch block wraps the processing logic. After implementing, the developer notices that when an exception occurs, the loop terminates prematurely instead of continuing. The code structure is: List<Record> records = fetchRecords(); for (Record rec : records) { try { process(rec); } catch (Exception e) { log.error("Failed to process: " + rec.getId(), e); } } What is the most likely reason for the premature termination?

Hard
62

What is the output when this code is executed? ```java int x = 2; switch (x) { case 1: System.out.print("One "); case 2: System.out.print("Two "); case 3: System.out.print("Three "); break; default: System.out.print("Default"); } ```

Medium
63

Which THREE statements about the switch statement in Java are correct?

Medium
64

A financial trading system uses a Java application to process market data. The core algorithm uses nested loops to compare price arrays. The developer uses a labeled continue statement to skip certain combinations. After a code review, the team suspects the algorithm has a bug that causes incorrect results. The developer writes a unit test and discovers that the labeled continue sometimes skips more iterations than intended. The code is: outer: for (int i = 0; i < prices1.length; i++) { for (int j = 0; j < prices2.length; j++) { if (prices1[i] < prices2[j]) continue outer; // process combination } } The developer intended that if any price in prices1 is less than a price in prices2, the entire row (i) should be skipped. However, the algorithm skips rows even when the condition is not met for all j. What is the most likely cause?

Hard
65

Which TWO statements about the switch statement in Java are true?

Easy
66

Which two of the following are valid ways to exit a loop in Java?

Medium
67

What is the output of the following code? ```java int i = 5; while (i > 0) { System.out.print(i + " "); i--; } ```

Easy
68

```java int count = 0; for (int i = 0; i < 5; ++i) { if (i == 3) break; count++; } System.out.println(count); ``` What is the output?

Medium
69

Given: Object obj = "Hello"; String result = switch(obj) { case String s -> "String of length " + s.length(); case Integer i -> "Integer"; default -> "Unknown"; }; What is result?

Medium
70

Given the following switch statement: ```java int x = 2; switch (x) { default: System.out.print("default "); case 1: System.out.print("1 "); case 2: System.out.print("2 "); case 3: System.out.print("3 "); break; case 4: System.out.print("4 "); } ``` What is the output?

Hard
71

Consider the following code: ```java boolean a = true, b = false, c = false; if (a && b || c) { System.out.println("True"); } else { System.out.println("False"); } ``` What is the output?

Easy
72

Which three of the following are valid case values in a traditional switch statement (non-pattern)?

Medium
73

A developer needs to iterate over a List<String> and remove elements that are null. Which approach guarantees correct behavior without throwing a ConcurrentModificationException?

Easy
74

How many times does the following loop execute? int i=0; while(i<5) { System.out.println(i); i++; }

Easy
75

Given: Object obj = null; String s = switch(obj) { case null -> "null"; case String str -> str; default -> "other"; }; What is the result?

Medium
76

Which change fixes the exception?

Hard

Frequently asked questions

What does the Controlling Program Flow domain cover on the 1Z0-829 exam?
RAM tests your ability to identify, install, and troubleshoot memory types, speeds, and configurations for PCs.
How many questions are in this domain?
This page lists all 76 Controlling Program Flow questions in the 1Z0-829 question bank. The actual exam draws from this domain proportionally to its weighting in the official exam blueprint.
What is the best way to practise this domain?
Start with a short focused session (10 questions) to identify gaps, then work through explanations. Repeat with a longer session once the weak areas feel solid.
Can I practise only Controlling Program Flow questions?
Yes — the session launcher on this page filters questions to this domain only. Choose any session length for inline explanations and scoring.
oracle-ocp-java17 ORACLE-OCP-JAVA17 program flow Practice Questions