Track one count through separate blocks

A food bank tracks packed boxes using the following fragment inside a Java method. Find the number printed by the first print statement and the number printed by the second. Enter both counts in boxes as exact integers.


Java
int packed = 24;
{
    int added = 8;
    packed = packed + added;
    System.out.println(packed);
}
{
    int added = 5;
    packed = packed + added;
    System.out.println(packed);
}
Your answers

Create a free account to get started

Unlock full course notes by signing up

  • Video lessons taught by top educators
  • Practice questions with guided solutions
  • Written review notes for reference
  • Expert answers anytime from course tutors

More Variable Declarations and Scope in Java Questions: