Computer Science › Primitive Data Types
Which of the following Boolean expression evalutes to True?
I. False && False && False && True && False
II. (False && False) || (True || False) || (False && (True || False))
III. (True && False) && (True || False || (True && True))
IV. !(True && True && False)
V. False || False || False || True || False
Which is true?
a = 4
b = 2
c = 5
d = 6
a) a = c - d
b) a = b - d
c) a = d - b
d) a = c * d
boolean x;
int y;
x = false;
y = 10;
x = !(y < 10 || y > 10);
System.out.println ( x );
What is printed?
Consider the following code:
int\[\] a = {8,4,1,5,1,5,6,2,4};
int b = 1;
boolean\[\] vals = new boolean\[a.length\];
for(int i = 0; i < a.length; i++) {
vals\[i\] = (a\[i\] - 1 > 4);
}
for(int i = 0; i < vals.length; i++) {
String s = "Duns Scotus";
if(!vals\[i\]) {
s = "Mithrandir";
}
System.out.println(s);
}
What is the output for the code above?
Consider the following code:
int\[\] a = {8,4,1,5,1,5,6,2,4};
int b = 1;
boolean\[\] vals = new boolean\[a.length\];
for(int i = 0; i < a.length; i++) {
vals\[i\] = (a\[i\] - 1 > 4);
}
for(int i = 0; i < vals.length; i++) {
String s = "Duns Scotus";
if(!vals\[i\]) {
s = "Mithrandir";
}
System.out.println(s);
}
What is the output for the code above?
boolean x;
int y;
x = false;
y = 10;
x = !(y < 10 || y > 10);
System.out.println ( x );
What is printed?
Which of the following Boolean expression evalutes to True?
I. False && False && False && True && False
II. (False && False) || (True || False) || (False && (True || False))
III. (True && False) && (True || False || (True && True))
IV. !(True && True && False)
V. False || False || False || True || False
Which is true?
a = 4
b = 2
c = 5
d = 6
a) a = c - d
b) a = b - d
c) a = d - b
d) a = c * d
int currentYear = 2016;
bool leapYear;
``
if (currentYear % 4 == 0) {
leapYear = true;
} else {
leapYear = false;
}
``
febDays = leapYear ? 28 : 29
Based on the code above, what value will febDays
have?
int currentYear = 2016;
bool leapYear;
``
if (currentYear % 4 == 0) {
leapYear = true;
} else {
leapYear = false;
}
``
febDays = leapYear ? 28 : 29
Based on the code above, what value will febDays
have?