Question
What is the scope of the variables whatAmI_1 , whatAmI_2 , and whatAmI_3 for the program? For each variable you need to address: (1) is
What is the scope of the variables whatAmI_1, whatAmI_2 , and whatAmI_3 for the program?
For each variable you need to address: (1) is it a global or local variable, (2) what method(s) can they be seen in and why, and (3) What are the values printed for each respective variable.
//CODE BEGINS HERE
public class Quiz {
public static String whatAmI_1 = "Can you tell me what my scope is?";
public static void main(String args[]) {
String whatAmI_2 = "What is my scope?";
System.out.println(whatAmI_1);
System.out.println(whatAmI_2);
callMe();
System.out.println(whatAmI_1);
System.out.println(whatAmI_2);
} // end main()
public static void callMe() {
whatAmI_1 = "Hello! What scope am I?";
String whatAmI_3 = "What variable scope am I?";
System.out.println(whatAmI_1);
System.out.println(whatAmI_3);
System.out.println();
} //end callMe()
}//end class
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started