...

/

Practice Challenges for Fun

Practice Challenges for Fun

In this lesson, we will go through some challenges using Java arithmetic expressions.

Quiz

Attempt the following quiz questions and check your understanding of Arithmetic Expressions.

What is the value of each of the following Java expressions?

1.

17 + 2 – 5 / 5

A.

18

B.

16

C.

4

D.

3


1 / 7

Classify each of the following Java assignment statements as either legal or illegal. Let b, s, i, l, f, and d be variables of type byte, short, int, long, float, and double, respectively.

1.

d = l

A.

Legal

B.

Illegal


1 / 6

If i, l, f, and d are variables of type int, long, float, and double, respectively, what is the data type of each of the following expressions?

1.

f + d

A.

int

B.

long

C.

float

D.

double


1 / 6
Technical Quiz
1.

Using Zeller’s congruence, what is the day of the week for March 17, 2020?

f = d + [(26 × (m + 1)) / 10] + y + [y / 4] + 6 × [y / 100] + [y / 400]
A.

Monday

B.

Tuesday

C.

Wednesday

D.

Thursday


1 / 2

Challenge 1: Find the cube

Write a Java statement that computes the cube of an integer ...