Decide when reusing a local name is legal

A shop program contains the following fragment inside a Java method, with no other declarations using these names. Which statements about the fragment or the proposed changes are true? Consider each proposed change independently. Select all that apply.


Java
int daily = 11;
{
    int extra = 2;
}
{
    int extra = 6;
}
Choose an answer

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: