333_20240624123259 Flashcards

1
Q

Why should Concepts of programming languages be studied?

A

Programming is new.
General language concept knowledge helps.
Increased ability to express ideas.
“ “ to learn new languages.
Helps choose appropriate languages.
Understand tradeoffs.
Overall advancement of computing

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

What are the Language Evaluation Criteria?

A

Readability, Writability, Reliability, Cost

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

What is Readability defined as?

A

The ease with which programs can be read and understood

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

What is Writability defined as?

A

The ease with which a language can be used to create programs

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

What is Reliability defined as?

A

Whether a language performs to its specifications under all conditions

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

What is Cost defined as?

A

cost of using the language

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

What is the Evaluation Criteria for Readability?

A

Overall simplicity: Manageable set of features and constructs(minimal feature multiplicity, minimal operator overloading)

Orthogonality: small set of primitive constructs can be combined in small number of ways

Data types; if types are missing, they must be simulated

Syntax considerations: Lack of naming restrictions increase readability (Identifier forms). More special words = more readable (Special words). meaningful keywords, avoid language constructs with same name and different meaning(Form and meaning)

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

Why is a lack of orthogonality bad?

A

It can lead to exceptions

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

Why is too much orthogonality bad?

A

bad for readability

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

What is the problem with too much simplicity?

A

Can be bad for readability

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

What is the Evaluation Criteria for Writability?

A

Simplicity and orthogonality: few constructs, small number of primitives, small set of rules for combining them

Support for abstraction: define and use complex structures/operations.(Process abstraction and Data abstraction)

Expressivity: convenient ways of specifying operations. Strength + number of operators and predefined functions

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

What is process abstraction?

A

Provision for subprograms

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

What is data abstraction?

A

classes, pointer & dynamic memory

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

What is the Evaluation Criteria for Reliability?

A

Type checking: Test for type errors. Compile time checking > run time checking

Exception handling: intercept run time errors and correct it

Aliasing: Presence of 2+ distinct referencing names for same memory location. (dangerous feature)

Readability and writability: non-natural ways of expressing algorithms = unnatural approaches = reduced reliability

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

What is the Evaluation Criteria for Cost?

A

Training new programmers.
Writing programs
compiling programs
Executing programs
Language implementation system (availability of free compilers)
Reliability(poor = high cost)
Maintaining programs

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

What are some extra Evaluation Criteria?

A

Portability : ease of moving from on implementation to another
Generality: applicability to a wide range of applications
Well-definedness: Completeness + precision of of language’s official definition

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

What are the Language Design trade-offs

A

Reliability vs cost of execution

Readability vs writability

Writability(flexibility) vs reliability

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

What are the programming domains?

A

Scientific Applications
Business Applications
AI
System Programming
Web Software

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

What influences the Design of a Language?

A

Computer Architecture
Programming Methodologies (eg OOP led to new programming paradigms)

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

What influenced Programming Methodologies?

A

1950/60: simple applications (machine efficiency)
1960s: Efficiency + readability + better control structures (structured programming + top-down design + step-wise refinement)
1970: Process- oriented -> data-oriented (data abstraction
1980: OOP (Abstraction + inheritance + polymorphism)

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

What are the Language Categories?

A

Imperative: Variables, assignment statements, iteration. has OOP languages. Includes visual languages. (c++ Java C ..)

Functional : Main means of computation, applying functions to parameters (LIST, Scheme)

Logic: Rule based (Prolog)

Markup/hybrid (XSLT, JSTL)

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

What are the Implementation Methods

A

Compilation: programs translated to ML

Pure Interpretation: Programs are interpreted by another program known as an interpreter

Hybrid: compromise between compilers and pure interpreters

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

What are the phases of Compilation

A

Lexical analysis: converts source characters to lexical units

Syntax Analysis: Transforms lexical units to parse trees

Semantics analysis: Generate intermediate code

Code generation: Machine code is generated

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

Is Compiled or Pure Interpreted programs faster

A

Compiled.
Interpreted programs are 10-100 times slower

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

Does Interpreted or compiled programs use more space

A

Interpreted.

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

What is an example of a Hybrid Implementation System

A

Perl, typical Java programs

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

What is Just-In-Time Implementation Systems

A

Translate programs to intermediate language
Compile the intermediate language into machine code when they are called

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

What uses JIT systems?

A

.NET languages

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

What are the different Programming environments?

A

UNIX, Microsoft Visual Studio.NET,NetBeans

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

When was Zuse’s Plankakul designed?

A
  1. Never implemented. Not published until 1972
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
31
Q

What was the environment for the development of Zuse’s. and what was it used for

A

Environment = limited hardware,limited impact

Use = wasnt implemented

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

Pseudocode environment and use

A

No specific environment

use = break bigger problems down into smaller ones

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

What was speedcoding created for?

A

IBM 701

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

Was Fortran 0 implemented?

A

no

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

What was the environment for Fortran 1 and use?

A

IBM 704 had little memory. Machine efficiency was very important.

use = business software/scientific computing

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

How was fortran II different from Fortran I?

A

More reliable and bug fixes

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

What was important about Fortran 77

A

It became the new standard in 1978

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

Why was Fortran important?

A

It changed how computers are used

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

Why was LISP created?

A

AI research needed a language to support

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

Why was LISP important?

A

It pioneered functional programming

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

Why was Scheme created and where is it used?

A

Created to promote functional programming.

used in computer science courses

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

What is COMMON LISP

A

Feature rich dialect of LISP (it combines features of several LISP dialects) (almost opposite of scheme)

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

Environment of development for ALGOL 60

A

No universal language for communicating algorithms.
No portable languages
Needed to design a universal language

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

What was the goal for ALGOL

A

it must be close to mathematical notation.
good for describing algorithms
must be translatable

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

When was ALGOL 58 implemented?

A

It was never implemented but variations of it was

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

Environment of development for COBOL

A

Only few proprietary business languages at the time

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

On what programming language is COBOL based on?

A

FLOW-MATIC

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

what is COBOL used for?

A

Transaction processing, Data security (business application language)

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

What was the environment of development for BASIC

A

Time sharing systems was on the rise

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

What was BASIC used for?

A

A general programming language.
first widely used language with time sharing

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

What was the environment of development for PL/I

A

Scientific users needed better I/O

Business users needed floating point + arrays

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

What was PL/I used for?

A

Business, Scientific and Engineering applications

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

What was bad about PL/I?

A

poorly designed. Too large and too complex

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

What was the 2 early dynamic languages?

A

APL and SNOBOL

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

What was APL designed as?

A

A hardware description language

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

What is orthogonality?

A

the ability to “mix” different data types and perform operations with them

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

What was SNOBOL originally used for?

A

Writing text editors

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

What was SIMULA 67 designed for?

A

system simulation

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

How did SIMULA 67 advance programming?

A

It introduced coroutines and the beginnings of data abstraction

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

What was the design of the ALGOL 68 based on?

A

Orthogonality

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

What did ALGOL 68 contribute?

A

user-defined data structures. reference types. dynamic arrays

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

For what was C developed?

A

systems programming at Bell Labs

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

What is Prolog based on?

A

Formal logic

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

What was history’s largest design effort?

A

Ada

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

What was Ada developed for?

A

US DoD

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

How many languages were in use by the DoD before Ada?

A

450+

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

What was Ada intended for?

A

Embedded system development

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

What did Ada contribute?

A

Packages, Exception handling, Generic Program units, Concurrency

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

What language had the first full implementation of true OO

A

Smalltalk

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

What did Smalltalk bring to the table?

A

Promoted GUI design and OOP paradigm

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

From where did C++ evolve from?

A

C + SIMULA 67

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

What was Java based on?

A

C++ without struct union and enum(enum is implemented as classes) or pointers

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

What is perl uses?

A

UNIX system text file processing, CGI programming. UNIX general system administration

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

What is PHP often used for?

A

Form processing + database access via the web

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

What is JavaScript used for?

A

Dynamic HTML documents

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

What was the 1st Japanese language to be widely used in US and what did it replace?

A

Ruby

Perl and Python

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

What is imperative language design based on?

A

von Neumann architecture with efficiency as primary concern

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

What is functional language design based on?

A

Mathematical functions

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

What are functional side effects?

A

When a function changes a parameter or a global variable

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

What is the problem with functional side effects?

A

Unpredictable, Concurrency issues

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

How to solve functional side effects?

A

1) No 2 way parameters, No non-local references in functions. but it is very inflexible

2) Demand fixed operand evaluation order. limits some complier optimizations

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

When does a program have referential transparency?

A

Any 2 expressions that are equivalent can be substituted for one another and it doesn’t affect the action.

There are no functional side effects

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

What is the advantage of referential transparency?

A

semantics are easier to understand

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

Are Pure Functional Languages referentially transparent? and why?

A

Yes. No global variables. parameter values are constants. functions cannot have state, value of function depends only on parameters

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

What is the objective of functional language designs?

A

mimic math functions as closely as possible

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

What are the LISP Data Objects and Structures?

A

Only consists of atoms and lists

2 types of atoms (symbols and numeric literals)

List = sequence of atoms or sublists

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

What does Scheme and Lisp have in common?

A

They use the same atoms and lists

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

What is Scheme interpreter interactive mode?

A

Mode that allows you to type code in line by line rahter than programming in an editor

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

Scheme interpreter is just a Scheme function?

A

Yes

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

How are functions evaluated?

A

Parameters (in no order)
values of parameters substituted into the function body
Value of last expression evaluated in the body is the value that the function defines

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

What are the Primitive Numeric Functions

A

+,-,*,/,abs,sqrt,remainder,min,max

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

Which primitive numeric functions cannot accept multiple parameters?

A

abs,sqrt,remainder

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

What are lambda functions used for?

A

Nameless functions

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

how many parameters can lambda functions have?

A

any number of parameters

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

how do you bind names to lambda expressions?

A

(define (square x) (* x x))

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

how do you bind a name to the value of an expression

A

(define pi 3.142) or (define two_pi (* 2 pi))

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

Hoe is the evaluation process for defined different?

A

Since the 1st parameter is a name and not a parameter it is not evaluated (otherwise it would be evaluated as undefined)

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

How do you output a expression in Scheme?

A

(display expression)

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

what is used for true and false in scheme?

A

t and #f (or () for false)

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

What are the predicate values for numbers with multiple parameters?

A

=, <>, > ,<, >= and <=

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

Predefined predicate functions for numbers, single value test.

A

even?,odd?,zero?,negative?,positive?

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

what does <> mean?

A

not equals

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

how does a if function look like?

A

(if predicate then_exp else_exp)
example
(define (divide number denom)
(if (<> denom 0)
(/ number denom) // returns this if true
0 // returns this if false
)
)

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

what is the cond function?

A

conditional control flow function

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

how does the cond function work?

A

“Accepts” the 1st expression that evaluates to true.
if no expression is true it goes to the else expression if there is one

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

how is repetition handled?

A

through recursion

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

how is a list created?

A

‘(A B) or (quote (A B))

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

how does “list” work in scheme?

A

(list ‘A ‘B ‘C) yields (A B C)
(list ‘A ‘B ‘(C D)) yields (A B (C D ))

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

How do you get the 1st element of a list?

A

(car list)

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

how do you get the remainder of a list after its 1st element has been removed?

A

(cdr list)

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

what does cons do?

A

outs the 1st oarameter into the 2nd parameter (a list) to make a new parameter

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

examples of cons

A

(cons ‘A ‘(B C)) = (A B C)
(cons ‘(A B) ‘(C D)) = ((A B) C D)
(cons ‘() ‘(A B)) = (() A B)
(cons ‘A ‘B) = (A . B)
(cons ‘(A B) ‘C) = (( A B) .C)

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

How many parameters does list? take?

A

1

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

What does the null? predicate function do?

A

Checks if the list is empty ( (()) is not an empty list)

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

what does eqv? do?

A

checks if 2 values are the same.
Doesnt work for lists but does work for (eqv? ‘A ‘A)

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

what does eq? check?

A

if the 2 parameters are the same object in memory (for 2 list parameters or numeric atoms the result is not reliable)

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

What is the general form of let?

A

(let ((name1 exp1)(name2 exp2))body that uses the names in the bindings)

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

what does the let construct yield?

A

the value of the last application

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

What does the member function do?

A

Checks if an atom is in a simple list

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

With which function do you check if 2 lists are equal?

A

equalsimp

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

how is equal different from equalsimp?

A

equalsimp = atoms, equal = atoms + lists

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

What does (append lis1 lis2) yield?

A

all elements of list 1 followed by all elements of list 2

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

When is a recursive function tail recursive?

A

When the recursive call is the last operation in the function

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

What does mapcar do?

A

“Does” the function to everything in the list
(define (add-two number)
(+ number 2))

(mapcar add-two ‘(1 3 5 7))

results in (2 5 7 9)

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

What is a function that builds code

A

A function that can build code that can be executed

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

What is LISP used for?

A

AI

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

What is scheme used for?

A

To teach intro to programming

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

Other name for Logic programming languages

A

Declarative Programming languages

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

How are logic programs expressed?

A

Form of symbolic logic

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

Is it declarative or procedural?

A

Declarative: Only specify the form of results

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

What is a proposition?

A

Logical statement that can be true or false

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

What does a proposition consist of?

A

1+ objects and Relationships among objects

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

What are the 3 basic needs of formal logic?

A

Express propositions
Express relationships between propositions
Describe how new propositions can be inferred from other propositions

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

What is 1st order predicate calculus.

A

Form of symbolic logic that is used for logic programming

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

Object representation in predicate calculus

A

Represent objects in propositions.

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

What is a constant in predicate calculus?

A

A symbol that represents a particular object

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

What is a variable in predicate calculus?

A

A symbol that can represent different objects at different times

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

Is variables in imperative languages the same as in predicate calculus?

A

No

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

What are the 2 types of propositions?

A

Atomic propositions
Compound propositions

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

How does atomic propositions differ from compound propositions?

A

Compound propositions represent mathematical relations (written like mathematical functions)

Atomic propositions are represented by compound terms

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

What are the 2 parts of a compound term?

A

Functor (function symbol that names the relation)

Ordered list of parameters (tuples)

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

Example of a compound term:

A

student(jon)
like(seth, osx)

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

What are the 2 forms of propositions?

A

Fact: (assumed to be true)
Query: Truth of a proposition is to be determined

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

Example of fact and query

A

Fact = Jon is a student
Query = Can you prove that Jon is a student?

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

What are compound propositions?

A

2+ atomic propositions where atomic propositions are connected by operators

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

What are the 5 logical Operators?

A

negation
conjunction
disjunction
equivalence
implication

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

How many logical operators are there?

A

5

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

What are the quantifiers and and what do they mean?

A

Universal (upside down A) AX.P -> For all X, P is True

Existential (Backwards E) EX.P -> There exists a value of X such that P is true

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

How do we infer facts from known propositions?

A

Using resolution since resolution is an inference principle

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

What does the unification process do?

A

Finds values for variables in propositions that allow the matching process to succeed

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

What is instantiation?

A

Assigning temporary values to variables to allow unification to succeed

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

What happens if matching fails when instantiating a variable?

A

You backtrack and instantiate the variable with a different value

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

Steps of Proof by Contradiction

A

Hypotheses (set of assumed propositions)
Theorem (new proposition we want to infer)
Goal (Negation of theorem stated as a proposition)
Proof by contradiction (Theorem proved by finding an inconsistency with the goal)

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

What are Horn Clauses?

A

An “if-then” statement

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

What are the different types of Horn Clauses?

A

Headed (single atomic propositions on the left)
Headless (Empty left side)

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

Headed Horn Clause example

A

Rich(X) ∨ WorksHard(X) ∧ OwnsBusiness(X)

Rich(X) (Someone is rich) is true if WorksHard(X) (they work hard) and OwnsBusiness(X) (they own a business) are both true.

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

Headless Horn Clause

A

father(bob, jake)
bob is the father of jake

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

What type of clauses are
1) Facts
2) Queries
3) Rules

A

1+2) Headless
3) Headed

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

Which is simpler, Logic programming semantics or imperative language semantics?

A

Logic programming

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

Overview of logic programming

A

Programs only state the form of the result (not how its computed)
Uses predicate calculus (descriptive

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

Difference between imperative and logic using a “Sort the list” example

A

imperative = Describe Alg. to sort the list. Computer executes the steps of the Alg

Logic = describe the characteristics of a sorted list

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

Why was prolog designed?

A

For natural language processing

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

When was prolog designed?

A

1970s

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

A constant, variable or structure describes what in prolog?

A

A term

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

What is a constant in prolog?

A

An atom on int

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

What do atoms consist of in Prolog?

A

string of letters, digits and underscores starting with a lowercase letter

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

What do variables consist of in Prolog?

A

String of letters, digits and underscores starting with a uppercase letter

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

What are the kind of statements in prolog?

A

Fact, Rule and Goal statements

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

Example of a fact statement:

A

male(bill)

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

Example of a specific rule statement:

A

(right side = if part, left = then part)
ancestor(mary, shelly) :- mother(mary, shelly).

171
Q

Example of a general rule

A

parent(X,Y) :- mother(X,Y).
X is parent of Y if X is mother of Y
or
sibling(X,Y) :- mother (M,X), mother, (M,Y), father(F,X), father(F,Y).

172
Q

Example of a goal statement (the statement that you want to prove)

A

?- man(fred)

173
Q

What are the different inferencing approaches in prolog?

A

Bottom-up/”forward chaining” = begin with facts and rules. attempt to find sequence of matches that leads to goal (building toward goal)

Top-down/backward chaining = begin with goal, attempt to find sequence of matches that leads to facts (break down)

174
Q

What is used when there are multiple sub goals in prolog?

A

Breadth-first search and DFS

175
Q

What is the problem with backtracking?

A

Can take lots of time and space

176
Q

What does the tracing model do in prolog?

A

Display variable instantiations at each step

177
Q

What are the 4 events of the tracing model?

A

Call (beginning of attempt to satisfy goal)
Exit (When a goal has been satisfied)
Redo (when backtracking occurs)
Fail (when goal fails)

178
Q

What does the “is” operator do in prolog?

A

Assigns variable a value
A is B/17 + C

179
Q

What is the difference between the LHS and RHS of the “is” operator in prolog?

A

RHS must be instantiated
LFS must NOT be instantiated

180
Q

Is Sum is Sum + number legal in prolog?

A

No. 1) it is not an assignment statement
2) LHS and RHS cannot be both instantiated and not instantiated

181
Q

Simple Arithmetic Example in Prolog

A

distance(X,Y) :- speed(X,Speed),time(X,Time),
Y is Speed * Time.

182
Q

What are the different types of list structures in Prolog?

A

Simple list: [apple, prune]
Complex list: [[a,b],son(x,bob)]
Empty list: []
List with head x and tail y: [X|Y]

183
Q

What is “_” in prolog?

A

An anonymous variable (is used to “ignore” something like the head of a list for example)

184
Q

What does the “member” proposition do in prolog?

A

Checks if X is a member of Y (member(X,Y))
It is also built in “function”

185
Q

What does append do in prolog?

A

Appends X to Y and makes list Z
append(X,Y,Z)

186
Q

What does the reverse proposition do in Prolog?

A

Reverses the list X and stores it in Y
reverse(X, Y)

187
Q

What are the deficiencies of Prolog?

A

Resolution order control
Closed-world assumption
The negation problem
Intrinsic limitations

188
Q

Why is resolution order control a deficiency of Prolog?

A

It has a unpredictable execution. (the order of execution isnt constant so it might take unexpected routes to the goal)
Programmer can affect efficiency by placing more likely success rules higher up in program

189
Q

Why is the negation problem a deficiency of Prolog?

A

It relies on Horn Clauses. If info is missing the closed-world assumption cant determine truth or falsehood. Which can lead to incomplete negation

190
Q

How is a cut denoted in prolog and what does it do?

A

Denoted by ! and subgoals to the left of the cut cannot be re-satisfied through backtracking

191
Q

What is the problem with closed world assumptions?

A

If the program answers false it isnt necessarily false but could also maybe just not be proven

192
Q

What is the problem with intrinsic limitations?

A

Some tasks are impossible to specify efficiently

193
Q

What are some applications of Logic Programming?

A

RDMS
Expert systems
Natural language processing

194
Q

What are variables an abstraction of?

A

Memory cells that are characterized by attributes

195
Q

What are some common problems with Names/identifiers?

A

What form can names take and are there special words reserved (keywords)

196
Q

What are the aspects of a name?

A

Length
use of special characters
Case sensitivity

197
Q

What is the problem when names are too short?

A

They cannot be connotative

198
Q

How does Fortran, C99, C++, C#, Ada and Java handle name length?

A

Fortran = 6 in F1, 31 in F95 and 63 in F 2003
C99 = No limit but only 1st 63 are significant, external names are limited to a max of 31
C++ = No limit but implementers often impose one
C# + ADA + Java = No limit and all are significant

199
Q

Special Characters in PHP, Perl and Ruby

A

PHP = All variable names need to start with $
Perl = Scalars use $ arrays use @ and hashes use a %
Ruby = Instance variable names begin with @, Class variables names begin with @@

200
Q

What is the disadvantages Of case sensitivity?

A

Decreased readability and write-ability

201
Q

Why are there special words?

A

To aid in readability by naming actions

202
Q

Can reserved words be user-defined?

A

Nope

203
Q

What is the problem with an excess in special words?

A

Name collisions are more likely to occur (COBOL has 300 reserved words)

204
Q

What are the 6 attributes of a variable?

A

Name
Address
Value
Type
Lifetime
Scope

205
Q

All variables have names? T/F

A

F

206
Q

Can there be different addresses at different execution times for variables?

A

Yes

207
Q

What is a alias?

A

When 2 variables can be used to access the same memory locations (pointers, references, and unions)

208
Q

Are aliases good for readibility or bad?

A

Bad (readers must remember all of them)

209
Q

What is the Value of a variable

A

Stores the content of a memory location is associated with

210
Q

What is the l-value of a variable?

A

The address (l-value = location value)

211
Q

What is the r-value?

A

Value of a variable (real value)

212
Q

What does the type define for variables?

A

How a value is stored in memory

213
Q

What are the possible binding times?

A

Language design time(binding operators symbols to operations)
Language implementation time (binding floating point type to a representation)
Compile time(Binding variable to type in C or Java)
Load time (Binding C++ local static to memory cell)
Runtime (binding nonstatic local variable to a memory cell)

214
Q

Whats the difference between static binding and Dynamic binding?

A

Static = occurs before run time
Dynamic = during execution

215
Q

What is type binding and what are the issues?

A

Binding of a variable to a type

How is a type specified and when does the binding take place

216
Q

What is explicit declaration?

A

statement used to declare types of variables. (int var )

217
Q

What is implicit declaration?

A

A default mechanism for specifying variable types.
Used in BASIC, Perl,Ruby, JS, PHP

218
Q

What is the Advantage and Disadvantage of Static type binding?

A

Adv: Writability

DisAdv : typographic errors cant be picked up by compiler

219
Q

What is type inferencing?

A

Determining the types of variables form context (C#, Visual B 9.0+, Haskell, ML, F#)

220
Q

What is the advantage + disAdv of dynamic type binding?

A

Adv: Flexibility

DisAdv: Cost + type error detection by compiler/interpreter is difficult

(JS,Python,ruby,PHP,C# (limited))

221
Q

What are the 3 stages of Storage bindings and lifetime?

A

Allocation, Deallocation, and lifetime of a variable

222
Q

What are the different categories of Variables by Lifetime?

A

Static
Stack-dynamic
Explicit heap-dynamic
Implicit heap-Dynamic

223
Q

What is Stack-dynamic variables?

A

Storage bindings created for variables when their declaration statements are elaborated

224
Q

Adv + DisAdv of Stack-dynamic variables

A

Adv: Allows recursion + conserves storage

DISAsv: Overhead of allocation + deallocation
Subprograms cannot be history sensitive
inefficient references

225
Q

How is Explicit heap-dynamic variables allocated?

A

By explicit directives, specified by the programmer, which takes effect during execution (The variables are nameless)
(int * p = new int(12))

226
Q

If Explicit heap-dynamic variables are nameless how are they referenced?

A

Through separate pointers or references

227
Q

Adv + DisAdv of explicit heap-dynamic variables?

A

Adv: Custom dynamic storage management

DisAdv: unreliable (difficult to use correctly)
inefficient
Difficult to implement

228
Q

How is Implicit heap-dynamic variables allocated?

A

Assignment (all strings and arrays in JS, PHP and Perl)

229
Q

Adv + DisAdv of Implicit heal-dynamic variables?

A

Adv: Flexible

DisAdv: Inefficient (most attribute binding is dynamic)
Loss of error detection

230
Q

What is the scope of a variable?

A

The range of statements over which it is visible

231
Q

What are the scope rules of a language?

A

The definition of how name references are associated with variables

232
Q

What are the approaches to scoping rules?

A

Static scope
Dynamic scope

233
Q

How does static scope work?

A

It is based on program text to connect name reference to a variable (compiler + reader must find the declaration)

234
Q

How do you find the declaration in a static scope?

A

Start at program local unit and continue search in increasingly larger enclosing scopes . Stop when found
void f(){
int i = 10; // declaration
for(…){
if(){i++; // local program unit} } }

235
Q

What are enclosing static scopes called?

A

Static ancestors(nearest static ancestor is called a static parent)

236
Q

In what languages are variable hiding in blocks?

A

C and C++

237
Q

What are the 2 parts of a let construct?

A

Part that binds names to values
2nd part uses the names defined in the first part

238
Q

What is the Declaration Order of C99,C++ and Java and C#?

A

C99,C++,Java C# = variable declarations can appear anywhere a statement can
C99 C++ and Java = Scope of local variables is from declaration to end of block
C++ Java and C# = Loop control variables can be declared in for loop header and scope restricted

239
Q

what is the variable scope in C#

A

The whole block that the variable appears in

240
Q

in which languages is this allowed?
{{int x} int x}

A

C99, C++, and Java but not C#

241
Q

What is the scope of variables in PHP?

A

The scope is from the declaration to end of program.

242
Q

How can global variables be accessed in PHP?

A

Through the $GLOBALS array and declaring it “global” in the function

243
Q

When can a global variable be assigned to in a function

A

When the variable is declared as global in the function

244
Q

What is the advantages and DisAdv of static scoping?

A

Adv: Works well in many situations
DisAdv: too much access is possible. local variables tend to gravitate towards becoming global. Subprograms also gravitate toward becoming global rather than nested

245
Q

What is Dynamic Scope based on?

A

The calling sequence of program units (not text layout like global scope)
To connect a variable reference to a declaration: Search through chain of subprogram calls that brought execution to the variable reference

246
Q

Advantage and DisAdv of Dynamic scoping:

A

Adv: Convenience
DisAdv: When a subprogram is executing, its variables are visible to all subprograms it calls. impossible to statically type check. Access to non-local variables is slower

247
Q

What is the referencing environment of a statement

A

The collection of all names that are visible in the statement

248
Q

When a language uses a static scope what variables are visible?

A

Local variables + all the visible variables in all of the active subprograms

249
Q

When a language uses a dynamic scope what variables are visible?

A

static scope + active subprograms have started execution and have not yet terminated

250
Q

How many times is a name bound to a value for names constants?

A

Only once

251
Q

What is the Adv of Named constants

A

Readability and reliability

252
Q

How is named constant bound statically vs dynamically?

A

Static : const int SIZE = 10 + 5

Dynamic: const int SIZE
Size = a + 1

253
Q

What are the 2 kind of named constant in C#

A

const <- static
readonly <- dynamic

254
Q

What does a data type define?

A

Collection of data objects with a range of value and how they are stored in memory.

255
Q

What does an object represent?

A

The instance of a programmer-defined type

256
Q

What is another name for a programmer-defined type?

A

Abstract data type

257
Q

Do all languages provide primitive data type?

A

Almost all of them

258
Q

What is special about Integers?

A

It is an exact reflection of the hardware therefore mapping is trivial

259
Q

How many different integer types are there?

A

May be as many as eight

260
Q

What are the advantages of unsigned integers?

A

It cant go below 0. So you can store a lot more data into the field

261
Q

Do Floating points model real numbers?

A

Yes but only as approximations

262
Q

What are the 2 floating point types?

A

float and double

263
Q

What is the standard for floating points?

A

IEEE Floating-Point Standard 754

264
Q

How many bits does double and float use?

A

double = 64 bits
float = 32 bits
for both 1 bit = signed bit

265
Q

in complex data types, what makes up each value?

A

a real part and an imaginary part (7 + 3j where 7 = real and 3 = imaginary

266
Q

Whats the advantages and DisAdv of decimals

A

Adv : accuracy
DisAdv : waste memory and limited range

267
Q

Why is an advantage of boolean values readability?

A

Simplicity and clear representation

268
Q

How is the primitive data type character stored?

A

numeric codings with most common being ASCII

269
Q

What are the different types of character encodings of primitive data types?

A

ASCII, UCS-2 (16 bit),32-bit Unicode(UCS-4)

270
Q

How are lists represented and what do they hold?

A

ordered sequence of (often) heterogeneous values
Typically represented as a linked list

271
Q

How does lists look like in F#?

A

[1;2;3]

272
Q

What does F# list functions have in common with Scheme?

A

List.head [1;2;3] is equal to car (only returns the 1st element = 1)
List.tail [1;2;3] is equal to cdr in scheme (returns the rest of the list besides the head = [2;3]

273
Q

Are Python lists mutable and what does it mean?

A

Yes. allows [3, 5.8 ,”grape”]

274
Q

How do you delete list elements in Python?

A

del myList[1]

275
Q

How does list comprehensions look like in Python?

A

list = [x ** 2 for x in range(12) if x % 3 == 0]

276
Q

Where is Type theory studied in?

A

Math, Logic, CS, Philosophy

277
Q

What is a union?

A

A type whose variables can store values of different types at different times during execution

278
Q

How many values can be assigned to a union at once?

A

1

279
Q

What are union types used for?

A

Representing Values with Multiple Possibilities

280
Q

What is the difference between Discriminated vs Free Unions

A

Disc = type checking, higher type safety, runtime errors less likely, clearer readability.

free = no type checking, lower type safety, runtime errors more likely, less clear readability

281
Q

union example in C

A

union flexType{
int intEl;
float floatEl;
};

union flexType u1;
u1.intEl = 12;
u1.floatEl = 22.8;
float x = u1.floatEl;
int y = u1.intEl;

282
Q

Example of Discriminant

A

type Shape is (Circle, Triangle, Rectangle);
type Colors is (Red, Green, Blue);
type Figure (Form: Shape) is record
Filled: Boolean;
Color: Colors;
case Form is
when Circle => Diameter: Float;
when Triangle =>
Leftside, Rightside: Integer;
Angle: Float;
when Rectangle => Side1, Side2: Integer;
end case;
end record;

“Form” is the discriminant

283
Q

Why are free unions unsafe?

A

They do not allow type checking

284
Q

Are Ada’s discrimination unions safe?

A

Yes

285
Q

What are pointer type variables?

A

memory addresses that reference a memory
(nil/null = doesnt refer to a memory cell)

286
Q

What are the 2 uses of pointers?

A

power of indirect addressing
manage dynamic memory

287
Q

What is the scope and lifetime of a pointer?

A

Scope = if declared inside function == only accessible in that function. if declared globally == anywhere

lifetime = until memory location it is pointing to isnt valid anymore

288
Q

What is the lifetime of a heap-dynamic variable?

A

Until the user deletes it, otherwise it will result in memory leaks

declared using “new” in c++

289
Q

Are pointers restricted as to the type of value to which they can point?

A

Yes. For type safety and memory management

290
Q

Are pointers used for dynamic storage management, indirect addressing, or both?

A

Both

291
Q

Should the language support pointer types, reference types, or both?

A

Depends. If type safety needed = reference types

292
Q

What are the 2 fundamental operations for pointers?

A

Assignment and dereferencing
int *p = &val;
j = *ptr <- deref

293
Q

What is the problem with pointers?

A

Dangling pointers (seg-faults/memory corruption)
Lost heap-dynamic variable (allocated heap-dynamic variable that is no longer accessible = memory leaks)

294
Q

What are reference type?

A

Similar to pointers but no pointer arithmetic allowed

295
Q

Is reference types or pointers safer?

A

Reference types

296
Q

What is the main purpose of reference types?

A

For parameters
void f(int &p){…}

297
Q

How does Java extend C++ reference variables?

A

Allows them to replace pointers entirely
references can refer only to object and not primitives

298
Q

What need to be done on pointers if they are used for dynamic storage management?

A

manual heap management is necessary

299
Q

Why cant pointers and references not be avoided?

A

need them for dynamic data structures

300
Q

What is type checking?

A

ensuring operands of an operator are of compatible types

301
Q

What is a compatible type?

A

Type that is either legal for the operator or is allowed under language rules to be converted by compiler

302
Q

What is a type error?

A

Application of operator to an operand of inappropriate type

303
Q

If all type bindings are static can nearly all type checking be static and why?

A

Yes. It tells the compiler the types upfront

304
Q

What is the Adv of a strongly typed language?

A

Detects all variable misuses causing type errors

305
Q

Out of the following languages which are strongly typed? C C++ Java C# ML and F#?

A

Java C# ML and F# with ML and F# being very strongly typed

306
Q

What are coercion and what does it do to typing

A

converts operands to same type and it causes type weakening since it can cause accidental type mismatches go undetected

307
Q

Which languages use coercions?

A

C++ Ada and Java

308
Q

What is type equivalence?

A

It defines when operands of 2 types can be substitutable with no coercion

309
Q

When are 2 variable name type equivalent?

A

Same declaration or declarations that use the same type name

310
Q

When are 2 variable structure type equivalent?

A

If their types have identical structures

311
Q

What are the 2 branches of type theory?

A

Practical (data types in commercial languages)
Abstract (typed lambda calculus and of interest only to theoretical computer scientists)

312
Q

What is a type system?

A

A set of types and rules that govern type use in programs

313
Q

What are expressions?

A

Fundamental means of specifying computations in a programming language

314
Q

What is needed to understand expression evaluation?

A

The orders of operator and operand evaluation

315
Q

What do arithmetic expressions consist of?

A

Operators
Operands
Parentheses
Function calls

316
Q

What are some design issues with Arithmetic expressions?

A

Operator precedence rules
Operator associativity rules
Order of operand evaluation
Are operand evaluation side effects restricted
Is user-defined operator overloading allowed?
What type mixing is allowed

317
Q

How many operators does a Unary/Binary/Ternary operand have?

A

Unary = 1
Binary = 2
Ternary = 3

318
Q

Typical precedence levels of a language

A

Parentheses. Unary operators. ** or ^. * and /. + and -

319
Q

Operator associativity rules

A

Define order in which adjacent operators with the same precedence level are evaluated

320
Q

Typical associativity rules

A

Left to right (** = right to left)

321
Q

How are operators implemented in Ruby?

A

As methods
(Arith, relational, assignment)

322
Q

Can you overwrite operators in Ruby?

A

Yes because they are methods

323
Q

Scheme and Common LISP arithmetic and logic operations are implemented as?

A

Explicitly called subprograms

324
Q

Operand Evaluation Order

A

Variables, Constants, Parenthesized expressions

325
Q

Problematic operator overloading

A

& in C and C++. Loss of readability and loss of compiler error detection

326
Q

Can user-defined overloaded operators increase readability?

A

Yes but only when sensibly used (+)

327
Q

What is narrowing conversions in Type Conversions

A

Converts an object to a type that cannot include all of the values of the origin type (float to int)

328
Q

What is widening conversion in Type Conversions

A

Converts an object to a type including at least approximations of all the original type’s values. May lose accuracy (int to float)

329
Q

What is Mixed-mode expression?

A

Expression that has operands of different types. ( a is int, b is float. a + b = mixed mode)

330
Q

What is Coercion in Type Conversions?

A

The auto type conversion of operands. Decreases compiler’s type error detection ability.

331
Q

What is explicit type conversion?

A

Programmer-specified type conversions. Can be either narrowing or widening? Compiler may give warnings. ( (int) in C languages)

332
Q

What causes errors in expressions with type conversions?

A

Type checking and coercion.
Limitations of arithmetic, Inherent and computer.
Run time errors can be ignored but may require exception handling mechanisms

333
Q

What do relational expressions evaluate to?

A

Booleans

334
Q

What does short circuit evaluation do?

A

Doesnt evaluate all operands and operators (13a)(b) if a = 0 b isnt evaluated

335
Q

When can short circuit evaluation be a problem?

A

When there are side effects in expressions.

336
Q

What is the problem with = overloading

A

There is ambiguity between assignment and equality

337
Q

What are conditional targets?

A

Similar to conditional expressions ($flag ? $total : $subtotal

338
Q

How does a compound assignment operator look like?

A

A += B

339
Q

Can assignments also be mixed-mode?

A

Yes

340
Q

What is a control structure?

A

A control statement and the statements whose execution are controlled

341
Q

What is the most important design question for control structures?

A

Should a control structure have multiple entries

342
Q

What does a selection statement provide?

A

A choice between 2+ execution paths

343
Q

What are the 2 categories for selection statements?

A

2 way selectors and Multiple way selectors.

344
Q

What is the general form of a 2 way selection statements

A

if then else

345
Q

How are compound statements usually delimited as?

A

Square braces

346
Q

Are statement sequences contained in blocks?

A

No.

347
Q

To disambiguate nested selectors:

A

Match else with nearest if.
Force semantics ({})

348
Q

What are the design issues with multiple way selectors?

A

What is the control expression’s form and type.
How are selectable segments specified.
Is execution in structure only a single selection
How are case values specified
How are unrepresented expression values handled

(switch case in c c++ Java and JS)

349
Q

Can a if statement be a multiple way selector?

A

Yes. if elif elif elif …

350
Q

What are the 2 types of iterative statements?

A

Iteration
Recursion

351
Q

What are the design issues for iterative statements?

A

How are the iterations controlled
Where is the control mechanism in the loop

352
Q

What do Counting iterative statement have?

A

Loop variable.
variables intial, terminal and stepsize values

353
Q

What is the design issues for counter controlled loops design issues?

A

Type + scope of loop variable
Can loop variable be changed in loop body.
Should the loop parameters be evaluated only once?
What is the loop variable after the loop

354
Q

What is logically controlled loops?

A

Repetition control using Boolean expressions

355
Q

Which is more general? Counter or logical loops

A

Logical

356
Q

What are the design issues with logically controlled loops?

A

Should the control be pretest or posttest.
Should the loop be a special case of a count loop?

357
Q

What are user located loop control mechanisms?

A

Something like “break”

358
Q

What are iteration controlled data structures?

A

Iterations are controlled by number of elements in a data structure.

359
Q

How are iteration based structures controlled?

A

By a iterator

360
Q

What is unconditional branching?

A

Transferring control to specific place in program

361
Q

What are guarded comments?

A

If the order of evaluation is not important the program should not specify an order

362
Q

What is the form of a guarded loop?

A

do bool1->statment1
[] bool2 -> statment2
[] …
od

363
Q

What are the 2 types of abstraction?

A

Process abstraction
Data abstraction

364
Q

What are the fundamentals of subprograms?

A

Single point of entry
If subprogram is called, calling program is suspended
After execution control is returned to the caller

365
Q

Basic definition for subprograms

A

Defines interface and action
Interface specifies how the subprogram is used + name + parameters +…
Actions: Specify hat it does (body)

366
Q

What is a subprogram header?

A

The 1st part of the subprogram definition.
Name kind parameters

367
Q

What is the difference between formal parameters and actual parameters?

A

Formal: Dummy variable in header. Used in subprogram
Actual: Values being passed in

368
Q

What is a parameter profile(signature)?

A

Number, order and types of parameters

369
Q

What is a protocol?

A

Parameter profile with function return types

370
Q

What is a subprogram declaration?

A

Provides subprogram protocol, but not its body (prototype (void doSomething(int);)

371
Q

What is the Parameter correspondence?

A

for a subprogram call we must match actual parameters to formal parameters.

372
Q

What is the advantage of Positional parameters?

A

1st parameter = 1st parameter etc…
It is safe and effective

373
Q

What is the disadvantage of Positional parameters?

A

reduced readability + error prone

374
Q

What is the advantage + disadv of Keyword parameters?

A

Adv: Avoid corespondence errors. can appear in any order (improved readability)
Dis: Memorize param names

375
Q

Can formal parameters have default values?

A

Yes

376
Q

How are variable number of parameters processed?

A

Like a list

377
Q

What are the 2 categories of subprograms?

A

Procedures (collections of statements that define parameterized computations)
Functions (resemble procedures but semantically modeled on mathematical functions)

378
Q

How does Procedures and functions differ?

A

Procedures: produce result by modifying
Functions: produce results by returning a value

379
Q

What is the adv and disadv of stack-dynamic variables?

A

adv: recursion + shared among subprograms
dis: time for allocation, initialization

380
Q

What is the advantage of static local variables?

A

Opposite of stack-dynamic local variables

381
Q

What are the 3 modes for parameters?

A

In mode formal parameter: received data from an actual parameter
Out mode: Sends data to an actual parameter
Inout mode: Both

382
Q

What are the 2 ways data transfer can take place?

A

Physical copy of a value
Transmit access path to value

383
Q

What are the 5 implementation models for parameter passing?

A

pass-by-value
pass by result
pass by value result
pass by reference
pass by name

384
Q

What mode is pass by value?

A

In mode

385
Q

How does pass by value work?

A

The value of the actual parameter is used in formal parameter
Normally implemented by copying
can be done by transmitting an access path

386
Q

What mode is pass by result and how does it work?

A

Out mode
Value of formal parameter is used to change corresponding actual parameter

387
Q

What mode is pass by value result and how does it work

A

inout mode
Formal params have local storage

388
Q

How does pass by reference work and what mode is it?

A

Passes an access path (implemented using a reference or pointer) Inout Mode

389
Q

What mode is pass by name and how does it work?

A

Uses textual substitution
All formal parameter occurrences are replaced by the appropriate actual parameter

390
Q

What is parameter type checking?

A

Testing if the actual & formal parameter types match
(important for reliability)

391
Q

What must happen if multidimensional arrays are passe as parameters?

A

Compiler must map array subscript references to values
Mapping function must know size of all dimensions

392
Q

What are some design considerations for parameter passing?

A

Efficiency
1 way or 2 way data transfer

393
Q

How are c# method pointers declared?

A

deleates key word

394
Q

What are the 3 binding options?

A

Shallow binding (“Normal”)
Deep binding ( static scope)
Ad-hoc binding

395
Q

What is a overloaded subprogram?

A

Same as overloaded function

396
Q

What are the 2 types of subprograms?

A

Generic (template)
Polymorphic
(Take different parameter types in different calls)

397
Q

What is ad hoc polymorphism?

A

Overloaded subprograms

398
Q

When are subprogram versions created?

A

At compile time

399
Q

How is a wildcard represented and what does it mean in C++?

A

? it means any object

400
Q

How are side effects reduced?

A

Parameters should ideally be in mode.

401
Q

What is a closure?

A

An Anonymous function (function without name)

402
Q

What is a coroutine?

A

A subprogram with multiple entry points.

403
Q

What is a symmetric control

A

When the caller and called coroutines exist on a more equal basis.

404
Q

What is a coroutine call named?

A

A resume

405
Q

What is quasi-concurrent execution?

A

When a coroutine interleaves their execution but it doesnt overlap

406
Q

What is abstraction?

A

A view of an entity that includes only most significant attributes

407
Q

How is process abstraction created?

A

By means of subprograms

408
Q

When did all languages start to support data abstraction?

A

Since 1980

409
Q

What are the 2 abstract data type conditions that is being satisfied?

A

Representation of object are defined in a single syntactic unit.
Representation of objects of the type is hidden from the program units that use these objects

410
Q

What is the Adv of representing objects in a single syntactic unit?

A

organization, modifiability, Each ADT can be compiled separately in own file.

411
Q

What are language requirements for ADTs?

A

Syntactic unit. A method to make essential parts of an ADT visible to client

412
Q

ADT example

A

struct

413
Q

What are parameterized ADTs also known as?

A

Generic classes

414
Q

What can ADTs store?

A

elements of any type

415
Q

What must any OOP language support?

A

ADT
Inheritance
Polymorphism

416
Q

Why is Inheritance needed?

A

Can increase productivity (reuse)

417
Q

What are some OO concepts?

A

ADT (classes)
class instances (objects)
class that inherits (derived/subclass)
parent class
subprograms defining operations on objects (methods)
Calls to methods (messages)
collection of an object’s methods (message protocol/interface)
2 parts in message (method name, dest object)

418
Q

What are the 2 kinds of variables in a class?

A

Class variables (one per class)
Instance variables (one per object)
same for methods

419
Q

What is Dynamic binding?

A

Polymorphic reference (pointer)

420
Q

When everything is an object what are the advantages and disadv?

A

Adv: elegance
Disadv: slow

421
Q

When you add objects to a complete typing system what happens?

A

Speed up simple operations
Results in confusing type system

422
Q

When using an imperative typing system for primitives and make everything else object what happens?

A

Simple operations can be fast but typing system remains small
but 2 type systems has to mix

423
Q

What does dynamic binding look like in C++?

A

virtual key word, interface in java