Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Please Solve this by Java Question 2 (8 points) - Ec-static! The following is code of a person experimenting with static versus non-static (instance) variables
Please Solve this by Java
Question 2 (8 points) - Ec-static! The following is code of a person experimenting with static versus non-static (instance) variables and methods. In the code below, pick the line numbers (to cross out) in the below lines of code that will produce a compilation error. 1 public class ClassA { 2 3 4 public int a; public static int b;B public ClassA () { a 0; b = 0; 5 7 8 } 9 10 public void foo () { 11 System.out.println("a: " + a);B 12 System.out.println("b: " + b)%;B 13 } 14 15 16 17 public static void bar () { System.out.println("a: System.out.println("b: " + a); " + b); 18 } 19} 20 21 public class Driver { public static void main(String[] args) { ClassA myA = new ClassA (); myA.a 1; 22 23 24 25 26 27 28 29 30 31 32 33} myA.b = 1; myA. foo(); myA.bar(); ClassA. a = 2; ClassA.b = 2; ClassA.foo(); ClassA.bar();
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