Intro to programming UNIT 3 Flashcards

1
Q

What is a ternary operator

A

The ternary operator is a short if else statement in one line. It takes three operands

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

What operands does a ternary operator take. In what order

A
  1. The condition being tested
  2. Value if true
  3. Value if false

ex:
condition ? value if true : value if false

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

What does the && operator do and what is it’s logical table?

A

The && Operator is for logical AND. Both operands need to be true for it to return as TRUE

side 1 side 2 result
false false false
true false false
false true false
true true true

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

What does the || operator do and what’s it logic table

A

The || Operator is for logical OR. Either or both operands need to be true for it to return as TRUE

side 1 side 2 result
false false false
true false true
false true true
true true true

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

What is the logical not operator?

A

Using the (!) exlamation mark

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

How do you invert the && or the || operator?

A

You add the exclamation mark before
ex:
!||
!&&

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

What is called an inverse of an or?

A

NOR or NOT OR

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

What is the inverse of an and

A

NAND

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

What is the Logical XOR or Exclusive OR or Bitwise comparison operator?

A

Using the caret or ^ symbol

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

What is the XOR operator truth table?

A

Both sides cannot be the same for the operator to return as true

false false false
true false true
false true true
true true false

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

What is the XOR of

0001
0011

A

Result 0010

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

What evaluations can you use in a SWITCH statement

A

You can only use equality operators in a switch evaluation. Therefore you cannot use > < operators only ==

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

What’s the structure of a switch statement?

A

switch(toBeEvaluated) {
case 1:
break;

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

What is default for a switch?

A

Default is the case that will be run if no matches are found. It needs to be placed at the bottom of the switch case

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

What is a TRAILING ELSE BLOCK

A

It’s the default case that executes if none of the other cases evaluate to true

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

What is range testing?

A

It’s the testing of a value to see if it fits between set constraints

17
Q

What operator does the inside the fence check use?

A

It uses the AND Operator

18
Q

What operator does the outside the fence check use?

A

It uses the OR Operator

19
Q

What datatypes can be evaluated in a switch statement

A

It can only be used with items that can be compared for equality. Therefore you cannot evaluate doubles, floats and items that are not whole.

20
Q

What datatypes can you use in a switch

A

Int
Char
Strings

21
Q

What isn’t required in a default switch case?

A

You do not need a break statement. Since it will already be the last case to be evaluated.

22
Q

What happens when you compare Object with the “==” equality operator

A

It checks to see if it’s the same object. It will not necessarily check the data in them. Ex: Comparing string objects

23
Q

How do you compare string objects?

A

stringOne.equals(stringTwo);

This will return a boolean value. If both char arrays match it will return true. False if not matching.