Unit 3 Quiz Review- Boolean expressions and Operators

Unit 3 Quiz Review- Boolean expressions and Operators

11th - 12th Grade

9 Qs

quiz-placeholder

Similar activities

AIJ KD 3.2

AIJ KD 3.2

11th Grade

10 Qs

Python Booleans

Python Booleans

11th Grade

10 Qs

Processor architecture

Processor architecture

9th - 12th Grade

10 Qs

Is there a stock bubble?

Is there a stock bubble?

12th Grade

11 Qs

2425 Microcomputer Systems and Operating Systems Quiz

2425 Microcomputer Systems and Operating Systems Quiz

9th - 12th Grade

12 Qs

L. 4. Introduction to Hypertext Pre-Processor - 5

L. 4. Introduction to Hypertext Pre-Processor - 5

12th Grade

10 Qs

ABREVIATURAS INFORMÁTICAS Quiz

ABREVIATURAS INFORMÁTICAS Quiz

11th Grade

10 Qs

Random Facts 2

Random Facts 2

KG - University

10 Qs

Unit 3 Quiz Review- Boolean expressions and Operators

Unit 3 Quiz Review- Boolean expressions and Operators

Assessment

Quiz

Computers

11th - 12th Grade

Hard

Created by

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

Media Image

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