A. The Core Execution Principle:
A Nested Loop is simply a loop inside another loop. The fundamental rule governing nested loops is:
"For every SINGLE iteration of the Outer Loop, the Inner Loop executes completely through all its iterations from start to finish."
for (int i = 1; i <= 3; i++) { // Outer loop (controls ROWS)
for (int j = 1; j <= 4; j++) { // Inner loop (controls COLUMNS)
System.out.print("* "); // Prints elements in current row
}
System.out.println(); // Advances to next line after row finishes
}
B. Total Iterations Formula:
If the outer loop executes $M$ times and the inner loop executes $N$ times for each outer step, the total number of times the innermost body statement executes is:
$$ ext{Total Executions} = M imes N$$In the code above: $3 ext{ rows} imes 4 ext{ columns} = 12 ext{ asterisks printed}$.