Question: Which two method names, when filled into the print2() method, produce the same output as the print1() method? Assume the input arguments for each represent
Which two method names, when filled into the print2() method, produce the same output as the print1() method? Assume the input arguments for each represent the same non-null numeric value.

A. decrementAndGet() and getAndIncrement()
B. decrementAndGet() and incrementAndGet()
C. getAndDecrement() and getAndIncrement()
D. getAndDecrement() and incrementAndGet()
E. None of the above.
public static synchronized void print1(int counter) { System.out.println(counter--); System.out.println(++counter); } public static synchronized void print2 (Atomic Integer counter) { System.out.println (counter.. } System.out.println(counter..
Step by Step Solution
3.26 Rating (149 Votes )
There are 3 Steps involved in it
The given Java code contains two methods print1 which accepts an int parameter and print2 which acce... View full answer
Get step-by-step solutions from verified subject matter experts
