Separate the desk count from the class count

A parcel desk uses the following Java class. The field named parcels belongs to the class; ParcelDesk.parcels explicitly accesses it. Assume report() is called once, with the field initially holding its declared value.


Java
class ParcelDesk {
    static int parcels = 63;

    static void report() {
        int parcels = 18;
        int localStart = parcels;
        ParcelDesk.parcels = ParcelDesk.parcels - 7;
        parcels = parcels + 4;

        System.out.println(localStart);
        System.out.println(parcels);
        System.out.println(ParcelDesk.parcels);
    }
}


Enter the three printed counts: the saved starting count, the final local count, and the final field count. Give each as an exact integer number of parcels.

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: