Line trace: swapping two values with temp 🌶️
Below is a method that swaps two values using a temp variable. Trace a, b, and temp immediately after each labeled line executes.
public void swap() { int a = 5; int b; b = 3; int temp = a; a = b; b = temp;}
1. Trace a, b, and temp after each line executes.
If a variable hasn't been declared, write DNE for Does Not Exist. If a variable has been declared but not initialized, write ?. Otherwise, fill in the value of each variable immediately after the labeled line finishes executing.
Your score for your class is recorded when you click Submit all — checking individual questions doesn't save it. You can submit again to improve your score; your best one counts.