
Unit 3 Quiz Review- Boolean expressions and Operators
Quiz
•
Computers
•
11th - 12th Grade
•
Hard
Michael Courtright
Used 2+ times
FREE Resource
Enhance your content in a minute
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.
Access all questions and much more by creating a free account
Create resources
Host any resource
Get auto-graded reports

Continue with Google

Continue with Email

Continue with Classlink

Continue with Clever
or continue with

Microsoft
%20(1).png)
Apple
Others
Already have an account?
Similar Resources on Wayground
10 questions
Python If Statements - and or not
Quiz
•
11th Grade
10 questions
C#
Quiz
•
11th Grade
10 questions
Code.org Unit 5 Vocab Quiz 1
Quiz
•
9th - 12th Grade
10 questions
Variables and Data Types
Quiz
•
10th - 12th Grade
10 questions
Website Development - Lesson 2 Retrieval
Quiz
•
11th Grade
10 questions
Website Development 1 - Recall
Quiz
•
11th Grade
10 questions
Python Variables
Quiz
•
7th - 12th Grade
10 questions
Unit 1 Review AP CSP
Quiz
•
9th - 12th Grade
Popular Resources on Wayground
15 questions
Fractions on a Number Line
Quiz
•
3rd Grade
20 questions
Equivalent Fractions
Quiz
•
3rd Grade
25 questions
Multiplication Facts
Quiz
•
5th Grade
54 questions
Analyzing Line Graphs & Tables
Quiz
•
4th Grade
22 questions
fractions
Quiz
•
3rd Grade
20 questions
Main Idea and Details
Quiz
•
5th Grade
20 questions
Context Clues
Quiz
•
6th Grade
15 questions
Equivalent Fractions
Quiz
•
4th Grade
