Question: 9. Java allows declaration within a method of a field as a local variable or method parameter (e.g. String customerName) with the same name as

9. Java allows declaration within a method of a field as a "local" variable or method parameter (e.g. String customerName) with the same name as a field already declared (outside of the method) as an "instance" variable. Since the local variable will be allocated on the STACK, and the instance variable will be allocated in the program object in DYNAMIC memory, the compiler can generate code which will safely create two fields with the same name in these separate "name spaces". The compiler allows this to encourage the good coding practice of calling a data field containing a given value by the same name no matter where it is allocated in memory. In a method that has declared such a duplicate-name field we must qualify our reference to the field to clarify which one (local or instance) we are talking about. Question: What would be the statement in the method to save the customerName field provided as a method parameter in the instance variable field of the same name
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
