Level 3 - Conditionals & Loops Flashcards

1
Q
int s=1;
for (int j = 3; j >= 0; j--)
{
s = s + j;
}
System.out.println(s);
A

7

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

if (amHappy)

could also be written as:

A

if (amHappy == true)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

if (!amHappy)

could also be written as:

A
if (amHappy == false)
//or 
if (amHappy != true)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

In Java, how do you test to see if string myName equals Joey?

A

if ( myName.equals(“Joey”) )
//or
if ( myName.equalsIgnoreCase(“joey”) )
//if you want to ignore case

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

If ( (amHappy) && (tonight) )

could be written as:

A

if (amHappy==true && tonight==true)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

If ( (amHappy) | | (tonight) )

could be written as:

A

if (amHappy==true || tonight==true)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the boolean operator for “and?”

A

&&

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is the boolean operator for “or?”

A

||

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the boolean operator for “equal to?”

A

==

How well did you know this?
1
Not at all
2
3
4
5
Perfectly