Question: 2. Consider the following class definition: class Q2 { } private int count; public Q2 () { count = 1; } public void increase
2. Consider the following class definition: class Q2 { } private int count; public Q2 () { count = 1; } public void increase () { } count++; public int getCount () { return count; } (a) What's the output of the following user method? public static void testl () { } Q2 obj = new Q2 (); obj.increase (); obj.increase (); System.out.println( obj.getCount () ); (b) What's the output of the following user method? public static void test2 () { } Q2 obj1 = new Q2 (); Q2 02 obj2 = new Q2 (); obj1.increase (); obj2. increase (); System.out.println (obj1.getCount() ); System.out.println (obj2.getCount() );
Step by Step Solution
3.42 Rating (142 Votes )
There are 3 Steps involved in it
Question Answer a 3 on same object of Q2 increase function ... View full answer
Get step-by-step solutions from verified subject matter experts
