Chapter 6 Flashcards

1
Q

What is a data type?

A

A collection of data values and a set of predefined operations on those values.

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

What is a variable’s descriptor?

A

A collection of attributes.

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

What is a primitive data type?

A

Built-in data types.

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

What are some examples of primitive data types?

A

Integers, floating point, complex (FORTRAN, Python), decimal, boolean, and char

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

How are these primitive data types stored or represented? Non-aggregate. ints, floats, chars, etc.

A

As a string of bits in memory.

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

For character/string data types, what are the major design issues?

A

-Should they be static or dynamic?
-Are they built-in or not?
-What operations are allowed?
-How to store the string?
-How can we store dynamic strings?
-How to indicate length?

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

What is an array?

A

A contiguous chunk of memory of the same data type.

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

What are the design issues associated with arrays?

A

-What are the legal indices?
-Are accesses range-checked?
-When does a range for an array get bound?
-When is the memory allocated?
-Can multidimensional arrays be jagged? Rectangular? Both?
-Can you slice an array?

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

What is a rectangular array?

A

A multidimensioned array in which all of the rows have the same number of elements and all of the columns have the same number of elements.

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

What is a jagged array?

A

An array where the lengths of the rows need not be the same.

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

What is a slice of an array?

A

Some substructure of that array

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

What is an associative array? How is this different than a regular array?

A

An unordered collection of data elements that are indexed by an equal number of values called keys. Keys need to be stored in the structure, which differs from regular arrays.

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

What is a record type?

A

An aggregate of data elements in which the individual elements are identified by names and accessed through offsets from the beginning of the structure.

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

How do various languages implement records? For example, how does C implement a record?

A

C, C++, C#, and Swift: structs

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

What is a tuple?

A

A collection which is ordered and unchangeable. Similar to records, but the elements are unnamed.

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

What is a list?

A

An ordered collection.

17
Q

What is a pointer?

A

A variable that points to a memory location.

18
Q

What are the major design issues when dealing with pointers?

A

-What are the scope and lifetime of a pointer variable?
-What is the lifetime of a heap-dynamic variable (the value a pointer
references)?
-Are pointers restricted as to the type of value to which they can point?
-Are pointers used for dynamic storage management, indirect addressing,
or both?
-Should the language support pointer types, reference types, or both?

19
Q

What is a dangling pointer?

A

A pointer that lost its target.

20
Q

What is a lost pointer?

A

A pointer that is no longer accessible to the user program.

21
Q

What are solutions to dangling pointers and lost pointers?

A

-Dangling pointer: Assign pointer to null
-Lost pointer: Deallocate memory before termination of the program

22
Q

What is type checking?

A

Ensuring that the operands of an operator are of compatible types.

23
Q

What languages enforce type checking?

A

C, C++, Java, JavaScript, PHP

24
Q

What languages don’t enforce type checking?

A

Smalltalk, Ruby, Python

25
Q

What is strong typing?

A

A programming language is strongly typed if type errors are always detected.

26
Q

What is type equivalence?

A

Two types are equivalent if an operand of one type in an expression can be substituted for one of the other type, without coercion.