Answer:
Race Condition is possible if husband and wife both have concurrent functionality.
Explanation:
For eg. if Balance = 3000 and husband withdraws = 1000 then remaining balance is = 2000.
One the other hand if balance is 3000 and wife deposits =1000 then remaining balance is 4000
we can see that there is inconsistency that is not acceptable.
To solve the problem mostly we are using Peterson's Algorithm
Account can be used for husband and wife,
int flag = 0
boolean account
1 :Husband
do{
account[i] =TRUE;
flag=(i+1)%2
while (account [(i+1)%2] && turn =(i+1)%2;
withdraw();
account[i] = FALSE
(remainder)
} While (TRUE);
This process can be repeat with (Wife) where i will be replaced by j ,i=0 or 1 and j =1 or 0
- flag identify which is going to access the bank account
- account make sire that 2 users are mutually exclusive
Proved the race condition is prevented
Answer:
B) At runtime, new Integer[2] is assigned to numberArray. This makes each element of numberArray an Integer object. So you cannot assign a Double object to it.
Explanation:
The Number class in Java is the superclass for the numbers. Once it is set to the Integer object, the values in <u>numberArray</u> must be all integers, we know that arrays can hold one type of value in Java. Assigning a double value is not allowed in this situation.
Answer:
F(x) = x*.25
Explanation:
the amount of miles (x) divided by 4 (four quarters in a mile) or just multiply by .25