
Unit 3 Quiz Review- Boolean expressions and Operators
Quiz
•
Computers
•
11th - 12th Grade
•
Hard
Michael Courtright
Used 2+ times
FREE Resource
9 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
Which of the following examples as Java expressions would return true?
20 < 40
20>=20
"Friend".equals("Friend")
20 <35 && 15 <= 15
All of the above
2.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
Which of the following is a valid statement for comparison of the weight of three items declared as w1, w2, and w3 of double data type?
I. (w1.compareTo(w2)==0) && (w2.compareTo(w3)==0)
II. (w1 >= w2) && (w1 >= w3)
III. (w1.equals(w2)) && (w1.equals(w3)
IV. (w1 >= w2) || (w1>=w3)
I only
III only
I and III
II and IV
II and III
Answer explanation
Relational operators are used to compare values. equals() and compareTo() are methods to compare objects.
3.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
You want to compare the names of employees at Switch Video Games and arrange them in ascending order to make search and filtering easier and faster.
Which of the following Java expression components would you use?
>
compareTo()
<
==
equals()
Answer explanation
The compareTo() method is the method that should be used to compare two String values.
4.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
A programmer needs to write a code for a login screen to access the learning resources of www.javaforstudents.com. There are two options to login to the portal:
enter registered user name
or
enter registered mobile number
Which operator should the programmer use to complete this task?
&
!
|
||
&&
Answer explanation
|| (OR) operator should be used by the programmer to fulfill one of the conditions to log in to the screen.
5.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
Consider the code segment.
System.out.println("Joe".compareTo("Harry"));
What will be the output of this code?
-2
compile time error
-3
2
3
Answer explanation
This will compare both the Strings, and the result will be the difference between Joe and Harry, or 2.
6.
MULTIPLE CHOICE QUESTION
2 mins • 1 pt
Consider the code below written to compare two objects.
My m1 = new My();
My m2 = new My();
System.out.println(m1==m2);
What will be the output of the above code?
false
true
0
1
-1
Answer explanation
The == operator checks for reference equality, and it will give false.
7.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Which Boolean operator is represented in the shaded portion of the Venn diagram below?
|
||
&
$
&&
Answer explanation
The shaded portion in the given the Venn diagram is known as intersection and it is represented as && (AND) operator.
8.
MULTIPLE CHOICE QUESTION
1 min • 1 pt
Which statement below is true for relational and logical operator?
Logical operators can have boolean operands only.
Relational operators can have boolean operands only.
Both statements can be used to compare String values.
Both statements can have int and double operands.
9.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
For relational and logical operators, both statements can return boolean values
True
False
Similar Resources on Wayground
7 questions
YCEP Quiz
Quiz
•
9th - 12th Grade
10 questions
PPT Chp 5 Review
Quiz
•
9th - 12th Grade
13 questions
1.5.1a/b - Computers in the Workforce & Automation
Quiz
•
12th Grade
10 questions
3. App Inventor Quiz (Practice)
Quiz
•
12th Grade
10 questions
L5 Python Knowledge Quiz
Quiz
•
9th Grade - University
10 questions
Technical Terms - Internet (A-Z) - T1
Quiz
•
12th Grade
11 questions
Control Structures - Selection in Python
Quiz
•
8th Grade - University
10 questions
HTML Elements Quiz
Quiz
•
9th - 12th Grade
Popular Resources on Wayground
10 questions
Video Games
Quiz
•
6th - 12th Grade
20 questions
Brand Labels
Quiz
•
5th - 12th Grade
15 questions
Core 4 of Customer Service - Student Edition
Quiz
•
6th - 8th Grade
15 questions
What is Bullying?- Bullying Lesson Series 6-12
Lesson
•
11th Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
15 questions
Subtracting Integers
Quiz
•
7th Grade
22 questions
Adding Integers
Quiz
•
6th Grade
10 questions
Exploring Digital Citizenship Essentials
Interactive video
•
6th - 10th Grade
