Computers and Technology

Consider the following code segment. boolean a = true;
boolean b = false;
System. out. print((a == !b) != false);
What is printed as a result of executing this code segment?
false
true
0
1
Nothing is printed because the expression (a == !b) != false is an invalid parameter to the System. out. print method.
The following code segment prints one or more characters based on the values of boolean variables b1 and b2. Assume that b1 and b2 have been properly declared and initialized.
if (!b1 || b2)
{
System. out. print("A");
}
else
{
System. out. print("B");
}
if (!(b1 || b2))
{
System. out. print("C");
}
else
{
System. out. print("D");
}
if (b1 && !b1)
{
System. out. print("E");
}
If b1 and b2 are both initialized to true, what is printed when the code segment has finished executing?
ABCD
ABD
AD
BD
BDE
Consider the following code segment.
String str1 = new String("Happy");
String str2 = new String("Happy");
System. out. print(str1.equals(str2) + " ");
System. out. print(str2.equals(str1) + " ");
System. out. print(str1 == str2);
What is printed as a result of executing the code segment?
true true true
true true false
false true false
false false true
false false false
Consider the following two code segments. Assume that variables x and y have been declared as int variables and have been assigned integer values.
I.
int result = 0;
if (x > y)
{
result = x - y;
System. out. print(result);
}
else if (x < y)
{
result = y - x;
System. out. print(result);
}
else
{
System. out. print(result);
}
II.
if (x < y)
{
System. out. print(y - x);
}
else
{
System. out. print(x - y);
}

answer
Answers: 3

Other questions on the subject: Computers and Technology

image
Computers and Technology, 23.06.2019 11:20, 1tzM3
Http is the protocol that governs communications between web servers and web clients (i. e. browsers). part of the protocol includes a status code returned by the server to tell the browser the status of its most recent page request. some of the codes and their meanings are listed below: 200, ok (fulfilled)403, forbidden404, not found500, server errorgiven an int variable status, write a switch statement that prints out the appropriate label from the above list based on status.
Answers: 2
image
Computers and Technology, 24.06.2019 00:30, petergriffin6772
Which boolean operator enables you to exclude a search term? a} not b} and c} or d} plus
Answers: 1
image
Computers and Technology, 24.06.2019 08:00, Maxxboogie
Can someone work out the answer as it comes up in one of my computer science exams and i don't understand the cryptovariables
Answers: 1
image
Computers and Technology, 24.06.2019 10:00, wwwcarolynzouowficz
3. what do the terms multipotentialite, polymath, or scanner mean?
Answers: 2
Do you know the correct answer?
Consider the following code segment. boolean a = true;
boolean b = false;
System. out....

Questions in other subjects:

Konu
Biology, 29.07.2019 03:00
Konu
Biology, 29.07.2019 03:00