Consider the code below: 3 public class Testclass { 4 private static int countl; private int count2; 6 7 public Testclass(int in1, int in2) { count1 = in1; count2 = in2; } public void addCount1() {...


Consider the code below:<br>3 public class Testclass {<br>4<br>private static int countl;<br>private int count2;<br>6<br>7<br>public Testclass(int in1, int in2) { count1 = in1; count2 = in2; }<br>public void addCount1() { count1++; }<br>public void addCount2() { count2++; }<br>8.<br>10<br>11<br>public String tostring() { return

Extracted text: Consider the code below: 3 public class Testclass { 4 private static int countl; private int count2; 6 7 public Testclass(int in1, int in2) { count1 = in1; count2 = in2; } public void addCount1() { count1++; } public void addCount2() { count2++; } 8. 10 11 public String tostring() { return "Testclass[" + counti + ", + count2 + "]"; } 12 13 14 //Normally I wouldn't put a main() in an object class public static void main(String[] args) { 15 16 17 Testclass tc1 = new Testclass(0,0); Testclass tc2 = new Testclass(1,1); 18 19 tc1.addCount1(); tc1. addCount2(); 20 21 22 tc2. addCount1(); tc2.addCount2(); 23 24 25 System.out.println(tc1); System.out.println(tc2); 26 27 28 29 } 30 The output for this code is: TestClass[3, 1] TestClass[3, 2] Explain why. Note: focus on the numbers in the output.

Jun 07, 2022
SOLUTION.PDF

Get Answer To This Question

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here