Consider the following code which converts temperatures given in Centigrade scale to Fahrenheit
scale and vice versa, using two threads. Once the conversion is finished, the program should check
whether there is a temperature value in the array which is the same in both the scales.
import java.util.*;
class Centigrade extends Thread{
double[] f_temp = null;
public Centigrade(double[] arr) {
f_temp = arr;
if
public void run() {
// converts the temperatures in f_temp to centigrade
for(int i = 0; i < f_temp.length; i++) {
f_temp[i] = ((£_temp[i] - 32)/9.0)*5;
}
,
class Fahrenheit extends Thread{
double[] c_temp = null;
public Fahrenheit (double[] arr) {
c_temp = arr;
+
public void run() {
// converts the temperatures in c_temp to fahrenheit
for(int i = 0; i < c_temp.length; i++) {
c_temp[i] = ((9.0/5.0)*c_temp[i]) + 32.0;
}
}
public class Test{
public static void main(String args[]) {
double temp_in_fahrenheit[] = {29.67, -40.0, 50.0, 32.0};
double temp_in_centigrade[] = {100.0, -92.54, 32.0, -40.0};
Centigrade cobj = new Centigrade(temp_in_fahrenheit) ;
Fahrenheit fobj = new Fahrenheit (temp_in_centigrade) ;
is the only temperature which is same in both the scales. Choose the correct option which
should be written in place of
, so that this program produces the result as
on
every execution.
A.B.C.D.
A published solution is not available for this question yet.
If the specified key is not already associated with a value or is associated with null, associates it
with the given non-null value. Otherwise, replaces the associated value with the results of the
given remapping function, or removes if the result is null.
Consider the code given below that uses the merge method to combine scores of players and
answer the question that follows.
Choose the correct option regarding the code.
A.
It generates the output:
B.
It generates the output:
C.
It generates the output:
D.
It generates
during runtime.
A published solution is not available for this question yet.
The Java code given below produces a toggle button. With the first click, the traffic signal should
be switched to green, with the next click it should be switched to red, and on the next click it
should be switched to green again, and so on. Based on the requirement, answer the question
that follows the code.
Choose the correct code segment inside method
such that the given
behaviour can be implemented correctly.
A.B.C.D.
A published solution is not available for this question yet.