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; } (a) What's the output of the following user method? public static void testl () { } Q2 obj = new Q2 ();

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

1 Expert Approved Answer
Step: 1 Unlock

Question Answer a 3 on same object of Q2 increase function ... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Computer Network Questions!