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

Stepwise Refinement

Stepwise Refinement

11th - 12th Grade

13 Qs

Kuiz Tahun 5- TMK

Kuiz Tahun 5- TMK

11th - 12th Grade

10 Qs

Jenis Data

Jenis Data

7th - 12th Grade

10 Qs

PHP nulmeting

PHP nulmeting

8th Grade - Professional Development

14 Qs

2ND QUARTER REVIEW 2

2ND QUARTER REVIEW 2

12th Grade

12 Qs

Strings in Swift

Strings in Swift

9th - 12th Grade

12 Qs

bài tập 11 tiết 7

bài tập 11 tiết 7

11th Grade

10 Qs

INTRODUCCION A LA PROGRAMACION

INTRODUCCION A LA PROGRAMACION

6th Grade - 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

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

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.

Access all questions and much more by creating a free account

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

Already have an account?