Answered step by step
Verified Expert Solution
Link Copied!

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 Javastudent submitted image, transcription available below

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Programming questions

Question

How has technology aided inventory management?

Answered: 1 week ago

Question

Who needs to be involved in inventory decisions?

Answered: 1 week ago