Chapter 7 Flashcards

1
Q

What is an expression?

A

The fundamental means of specifying computations in a programming language.

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

What is an operator?

A

A character that represents a specific mathematical or logical action or process.

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

What are the three types of operators?

A

-Unary
-Binary
-Ternary

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

How is order of operation determined?

A

Operator precedence rules

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

What can be used to change the default order of operation?

A

Parenthesis

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

What is a conditional expression? How are they implemented or written in various languages?

A

An expression you can use to select one of two values based on a boolean condition. Examples include if statements, guards in haskell, cond in racket, etc.

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

What is a side-effect?

A

When a function either changes one of its parameters or a global variable.

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

How can side-effects complicate expression evaluation?

A

If a variable is being referenced while being altered in a function, what is the value of the variable?

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

What is an overloaded operator?

A

Using the same operator for multiple purposes. For example, “+” in Java can add numbers or concatenate strings, “&” in C and C++ for binary operations and pointer stuff

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

What is type conversion?

A

The narrowing or widening of what a variable can hold

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

When does type conversion typically take place?

A

In an expression with more than 1 data types

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

What is a relational expression?

A

An operator that compares the values of its two operands. X < 7, Y > 6.

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

What is a Boolean expression?

A

-Expressions consisting of boolean variables
-Boolean constants
-Relational expressions
-Boolean operators that produce boolean values.

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

What is short-circuit evaluation?

A

An expression where the result was determined without evaluating all operators. For example, an IF statement with an AND clause but doesn’t need to evaluate the second part of the AND

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

How can short-circuit evaluation be used to protect an expression?

A

It can prevent errors that are caused by future expressions. For example, the expression while((index < listlen) && (list[index] != key)). If this wasn’t short-circuit evaluated, the there would eventually be an out of bounds error when index = listlen.

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

What is an assignment statement?

A

Allows the user to change the bindings of values to variables.

17
Q

How is assignment handled in various languages? For example, how does Haskell vs C do this?

A

C uses an = sign. Haskell uses lets (but immutable) or change the value through recursive calls or through a return call. Python, Lua, Ruby, Haskell, and Perl support multiple assignment.