Question: variable with the larger scope. Have a look at the example below: The overlapping scope is within sampleMethod, where both the variables are visible. In
variable with the larger scope. Have a look at the example below:
The overlapping scope is within sampleMethod, where both the variables are visible. In this case, if you access java applies shadowing protocol.
Now consider the following code:
public class worksheet
public static void mainString arg
ShadowingExample example new ShadowingExample;
example. ;
example.sampleMethod;
class ShadowingExample
int ;
public void sampleMethod
int ;
System.out.printlnthe value of local variable ;
System.out.printlnthe value of instance variable ;
what should be written in the second print statement so that the output is the value of the instance variable
What should be written in the first print statement so that the output is the value of the local variable
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
