Computer Science, asked by duragpalsingh, 24 days ago

Assume you have a class that holds two private variables: a and b. Which of the following
pairs can prevent concurrent access problems in that class? (Choose all that apply.)
A. public int read(int a, int b){return a+b;}
public void set(int a, int b){this.a=a;this.b=b;}
B. public synchronized int read(int a, int b){return a+b;}
public synchronized void set(int a, int b){this.a=a;this.b=b;}
C. public int read(int a, int b){synchronized(a){return a+b;}}
public void set(int a, int b){synchronized(a){this.a=a;this.b=b;}}
D. public int read(int a, int b){synchronized(a){return a+b;}}
public void set(int a, int b){synchronized(b){this.a=a;this.b=b;}}
E. public synchronized(this) int read(int a, int b){return a+b;}
public synchronized(this) void set(int a, int b){this.a=a;this.b=b;}
F. public int read(int a, int b){synchronized(this){return a+b;}}
public void set(int a, int b){synchronized(this){this.a=a;this.b=b;}}

Answers

Answered by lavish10313
0

Answer:

public void set(int a, int b){synchronized(b){this.a=a;this.b=b;}}

E. public synchronized(this) int read(int a, int b){return a+b;}

public synchronized(this) void set(int a, int b){this.a=a;this.b=b;}

F. public int read(int a, int b){synchronized(this){return a+b;}}

public void set(int a, int b){synchronized(this){this.a=a;this.b=b;}}

Answered by pranav9736
0

Answer:

In physics, a force is any interaction that, when unopposed, will change the motion of an object. A force can cause an object with mass to change its velocity, i.e., to accelerate. Force can also be described intuitively as a push or a pull. A force has both magnitude and direction, making it a vector quantity.

Explanation:

Sociology is defined as the study of human values, relationships, beliefs and society. An example of sociology is what someone is studying when they attend a religious service of a religion that isn't their own. noun.

Similar questions