Deck 6: Programming Languages

Full screen (f)
exit full mode
Question
Which of the following is not associated with object-oriented programming?

A) Inheritance
B) Resolution
C) Encapsulation
D) Polymorphism
Use Space or
up arrow
down arrow
to flip the card.
Question
Which of the following does not require a Boolean condition?

A) If- else statement
B) While statement
C) Assignment statement
D) For loop statement
Question
Which of the following is not a control statement?

A) If- else statement
B) While statement
C) Assignment statement
D) For statement
Question
Which of the following is not a possible value of the expression 4 + 6 / 2 - 1

A) 4
B) 5
C) 6
D) 10
Question
Which of the following is not a loop?

A) If -else statement
B) While statement
C) Repeat statement
D) For statement
Question
Most machine languages are based on the

A) Imperative paradigm
B) Declarative paradigm
C) Functional paradigm
D) Object-oriented paradigm
Question
Which of the following statements is not a resolvent of the following clauses? P OR Q OR ¬R¬P OR T ¬Q OR T R OR T P \text { OR Q OR } \neg R \quad \neg P \text { OR T } \quad \neg Q \text { OR } T \quad \text { R OR T }

A) Q OR -R OR T
B) T OR P
C) P OR -R OR T
D) Q OR T
Question
Which of the following is a means of defining similar yet different classes in an object-oriented program?

A) Inheritance
B) Parsing
C) Coercion
D) Code optimization
Question
Which of the following is not a way of referring to a value in a program?

A) Variable
B) Literal
C) Constant
D) Type
Question
Which of the following is not constructed by a typical compiler?

A) Source code
B) Symbol table
C) Parse tree
D) Object program
Question
Which of the following is an example of a language that is based on the functional paradigm?

A) LISP
B) PROLOG
C) C
D) C++
Question
Which of the following is not associated with the concept of data type?

A) Coercion
B) Boolean
C) Operator precedence
D) Strongly typed language
Question
Which of the following is not a parse tree of an expression based on the following grammar?
<strong>Which of the following is not a parse tree of an expression based on the following grammar?   </strong> A)  B)  C)   <div style=padding-top: 35px>

A)<strong>Which of the following is not a parse tree of an expression based on the following grammar?   </strong> A)  B)  C)   <div style=padding-top: 35px>
B)<strong>Which of the following is not a parse tree of an expression based on the following grammar?   </strong> A)  B)  C)   <div style=padding-top: 35px>
C) <strong>Which of the following is not a parse tree of an expression based on the following grammar?   </strong> A)  B)  C)   <div style=padding-top: 35px>
Question
Which of the following is a means of nullifying conflicts among data types?

A) Inheritance
B) Parsing
C) Coercion
D) Code optimization
Question
Which of the following is not a type of statement found in a typical high-level imperative programming language?

A) Imperative statement
B) Exclamatory statement
C) Declarative statement
D) Comment statement
Question
Positions within arrays are identified by means of numbers called

A) Indices
B) Parameters
C) Instance variables
D) Constants
Question
Which of the following is the scope of a variable?

A) The number of characters in the variable's name
B) The portion of the program in which the variable can be accessed
C) The type associated with the variable
D) The structure associated with the variable
Question
Which of the following is an example of a language that is based on the object-oriented paradigm?

A) LISP
B) PROLOG
C) C
D) C++
Question
Which of the following is ignored by a compiler?

A) Control statements
B) Declarations of constants
C) Function headers
D) Comment statements
Question
Which of the following is not a step in the process of translating a program?

A) Executing the program
B) Parsing the program
C) Lexical analysis
D) Code generation
Question
To say that a grammar is ambiguous means that ___________________________________________.
Question
In programming languages that use + to mean concatenation of character strings,the expression
"2x" + "3x"
will produce what result?
________________
Question
Indicate how each of the following types of programming languages is classified in terms of generation (first generation,second generation,or third generation).
A. High-level languages _____________
B. Machine languages _____________
C. Assembly languages _____________
Question
Which of the following can Prolog conclude from the following program? parent(jill,sue).
Parent(jill,sally).
Parent(john,sue).
Parent(john,sally).
Sibling(X,Y):- parent(Z,X),parent(Z,Y).

A) parent(jill, john)
B) sister(sue, sally)
C) sibling(sue, sally)
D) sibling(jill, sue)
Question
In addition to the function's name,what other information is contained in a typical function header?
____________________________________
Question
List four data types that occur as primitive types in many high-level programming languages.
____________________ ____________________
____________________ ____________________
Question
In the context of the object-oriented paradigm,a __________________ is an imperative program unit that describes how an object should react to a particular stimulus.
Question
In contrast to _______________ languages such as English and Spanish,programming languages are
considered _______________ languages and are rigorously defined by their grammars.
Question
What clause would produce the resolvent
P OR R OR S
when resolved with the clause
P OR ¬Q
__________________
Question
Based on the sketch of a class definition below,which methods can be invoked from outside an instance of the class?
class Example
{public void method1( )
{ ...}
private void method2( )
{ ...}
public void method3( )
{…}
private void method4( )
{ ...}
}
_________________________________________________________
Question
The following is a program segment and the definition of a function named sub.
The following is a program segment and the definition of a function named sub.   A. What value will be printed by the program segment if parameters are passed by value? ____________ B. What value will be printed by the program segment if parameters are passed by reference? ____________<div style=padding-top: 35px>
A. What value will be printed by the program segment if parameters are passed by value?
____________
B. What value will be printed by the program segment if parameters are passed by reference?
____________
Question
What general rule should be added to the Prolog program below so that Prolog can conclude that ice cream is better than spinach?
better(icecream,peanutbutter).
better(peanutbutter,spinach).
Question
Rewrite the following instructions using a single if- else statement.
if (X == 5)goto 50
goto 60
50 print(Z)
goto 100
60 print(Y)
100 ...
Question
The following is a program segment and the definition of a function named sub.
The following is a program segment and the definition of a function named sub.   A. What value will be printed by the program segment if X of function sub is a global variable? ___________ B. What value will be printed by the program segment if X of function sub is a local variable? ___________<div style=padding-top: 35px>
A. What value will be printed by the program segment if X of function sub is a global variable?
___________
B. What value will be printed by the program segment if X of function sub is a local variable?
___________
Question
A data structure in which all elements have the same type is called ___________________,whereas a ________________ may have elements of different types.
Question
List three items of information that would be contained in a typical parser's symbol table.
________________________
________________________
________________________
Question
What encoding system is commonly used to encode data of each of the following types?
A. Integer ___________________________
B. Real __________________________
C. Character ___________________________
Question
List two disadvantages of both machine languages and assembly languages that are overcome by high-level programming languages.
_____________________________________
_____________________________________
Question
In the context of the object-oriented paradigm,____________ are templates from which
____________ are constructed.We say that the latter is an instance of the former.
Question
Give three examples of key words that are often found in high-level imperative or object-oriented languages.
___________________ _____________________ ______________________
Question
Briefly describe the task of each of the following.
A.Lexical analyzer
B.Parser
C.Code Generator
Question
Explain the distinction between fruitful and void functions.
Question
In the context of the object-oriented paradigm,what is a constructor?
Question
Explain the distinction between a formal parameter and an actual parameter.
Question
Explain why the generation approach to classifying programming languages fails to capture the full scope of today's languages.
Question
Explain the distinction between the imperative and declarative programming paradigms.
Question
Based on the grammar below,draw a parse tree showing that the string "drip drip drip" is a Leak.
Question
Show that the grammar below is ambiguous by drawing two distinct parse trees for the string "drip drip drip."
Show that the grammar below is ambiguous by drawing two distinct parse trees for the string drip drip drip.  <div style=padding-top: 35px>
Question
What does it mean to say that a programming language is machine independent?
Question
Based on the Prolog program below,what goal should be used to find the siblings of sue?
parent(jill,sue).
parent(jill,sally).
parent(john,sue).
parent(john,sally).
sibling(X,Y):- parent(Z,X),parent(Z,Y).
Question
Explain the distinction between translating a program (in a high-level language)and interpreting the program.
Question
Explain the distinction between global and local variables.
Question
Why is the straightforward "goto" statement no longer popular in high-level programming languages?
Question
Explain why key words in a programming language are often reserved words.
Unlock Deck
Sign up to unlock the cards in this deck!
Unlock Deck
Unlock Deck
1/54
auto play flashcards
Play
simple tutorial
Full screen (f)
exit full mode
Deck 6: Programming Languages
1
Which of the following is not associated with object-oriented programming?

A) Inheritance
B) Resolution
C) Encapsulation
D) Polymorphism
B
2
Which of the following does not require a Boolean condition?

A) If- else statement
B) While statement
C) Assignment statement
D) For loop statement
C
3
Which of the following is not a control statement?

A) If- else statement
B) While statement
C) Assignment statement
D) For statement
C
4
Which of the following is not a possible value of the expression 4 + 6 / 2 - 1

A) 4
B) 5
C) 6
D) 10
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
5
Which of the following is not a loop?

A) If -else statement
B) While statement
C) Repeat statement
D) For statement
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
6
Most machine languages are based on the

A) Imperative paradigm
B) Declarative paradigm
C) Functional paradigm
D) Object-oriented paradigm
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
7
Which of the following statements is not a resolvent of the following clauses? P OR Q OR ¬R¬P OR T ¬Q OR T R OR T P \text { OR Q OR } \neg R \quad \neg P \text { OR T } \quad \neg Q \text { OR } T \quad \text { R OR T }

A) Q OR -R OR T
B) T OR P
C) P OR -R OR T
D) Q OR T
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
8
Which of the following is a means of defining similar yet different classes in an object-oriented program?

A) Inheritance
B) Parsing
C) Coercion
D) Code optimization
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
9
Which of the following is not a way of referring to a value in a program?

A) Variable
B) Literal
C) Constant
D) Type
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
10
Which of the following is not constructed by a typical compiler?

A) Source code
B) Symbol table
C) Parse tree
D) Object program
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
11
Which of the following is an example of a language that is based on the functional paradigm?

A) LISP
B) PROLOG
C) C
D) C++
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
12
Which of the following is not associated with the concept of data type?

A) Coercion
B) Boolean
C) Operator precedence
D) Strongly typed language
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
13
Which of the following is not a parse tree of an expression based on the following grammar?
<strong>Which of the following is not a parse tree of an expression based on the following grammar?   </strong> A)  B)  C)

A)<strong>Which of the following is not a parse tree of an expression based on the following grammar?   </strong> A)  B)  C)
B)<strong>Which of the following is not a parse tree of an expression based on the following grammar?   </strong> A)  B)  C)
C) <strong>Which of the following is not a parse tree of an expression based on the following grammar?   </strong> A)  B)  C)
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
14
Which of the following is a means of nullifying conflicts among data types?

A) Inheritance
B) Parsing
C) Coercion
D) Code optimization
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
15
Which of the following is not a type of statement found in a typical high-level imperative programming language?

A) Imperative statement
B) Exclamatory statement
C) Declarative statement
D) Comment statement
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
16
Positions within arrays are identified by means of numbers called

A) Indices
B) Parameters
C) Instance variables
D) Constants
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
17
Which of the following is the scope of a variable?

A) The number of characters in the variable's name
B) The portion of the program in which the variable can be accessed
C) The type associated with the variable
D) The structure associated with the variable
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
18
Which of the following is an example of a language that is based on the object-oriented paradigm?

A) LISP
B) PROLOG
C) C
D) C++
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
19
Which of the following is ignored by a compiler?

A) Control statements
B) Declarations of constants
C) Function headers
D) Comment statements
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
20
Which of the following is not a step in the process of translating a program?

A) Executing the program
B) Parsing the program
C) Lexical analysis
D) Code generation
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
21
To say that a grammar is ambiguous means that ___________________________________________.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
22
In programming languages that use + to mean concatenation of character strings,the expression
"2x" + "3x"
will produce what result?
________________
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
23
Indicate how each of the following types of programming languages is classified in terms of generation (first generation,second generation,or third generation).
A. High-level languages _____________
B. Machine languages _____________
C. Assembly languages _____________
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
24
Which of the following can Prolog conclude from the following program? parent(jill,sue).
Parent(jill,sally).
Parent(john,sue).
Parent(john,sally).
Sibling(X,Y):- parent(Z,X),parent(Z,Y).

A) parent(jill, john)
B) sister(sue, sally)
C) sibling(sue, sally)
D) sibling(jill, sue)
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
25
In addition to the function's name,what other information is contained in a typical function header?
____________________________________
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
26
List four data types that occur as primitive types in many high-level programming languages.
____________________ ____________________
____________________ ____________________
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
27
In the context of the object-oriented paradigm,a __________________ is an imperative program unit that describes how an object should react to a particular stimulus.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
28
In contrast to _______________ languages such as English and Spanish,programming languages are
considered _______________ languages and are rigorously defined by their grammars.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
29
What clause would produce the resolvent
P OR R OR S
when resolved with the clause
P OR ¬Q
__________________
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
30
Based on the sketch of a class definition below,which methods can be invoked from outside an instance of the class?
class Example
{public void method1( )
{ ...}
private void method2( )
{ ...}
public void method3( )
{…}
private void method4( )
{ ...}
}
_________________________________________________________
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
31
The following is a program segment and the definition of a function named sub.
The following is a program segment and the definition of a function named sub.   A. What value will be printed by the program segment if parameters are passed by value? ____________ B. What value will be printed by the program segment if parameters are passed by reference? ____________
A. What value will be printed by the program segment if parameters are passed by value?
____________
B. What value will be printed by the program segment if parameters are passed by reference?
____________
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
32
What general rule should be added to the Prolog program below so that Prolog can conclude that ice cream is better than spinach?
better(icecream,peanutbutter).
better(peanutbutter,spinach).
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
33
Rewrite the following instructions using a single if- else statement.
if (X == 5)goto 50
goto 60
50 print(Z)
goto 100
60 print(Y)
100 ...
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
34
The following is a program segment and the definition of a function named sub.
The following is a program segment and the definition of a function named sub.   A. What value will be printed by the program segment if X of function sub is a global variable? ___________ B. What value will be printed by the program segment if X of function sub is a local variable? ___________
A. What value will be printed by the program segment if X of function sub is a global variable?
___________
B. What value will be printed by the program segment if X of function sub is a local variable?
___________
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
35
A data structure in which all elements have the same type is called ___________________,whereas a ________________ may have elements of different types.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
36
List three items of information that would be contained in a typical parser's symbol table.
________________________
________________________
________________________
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
37
What encoding system is commonly used to encode data of each of the following types?
A. Integer ___________________________
B. Real __________________________
C. Character ___________________________
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
38
List two disadvantages of both machine languages and assembly languages that are overcome by high-level programming languages.
_____________________________________
_____________________________________
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
39
In the context of the object-oriented paradigm,____________ are templates from which
____________ are constructed.We say that the latter is an instance of the former.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
40
Give three examples of key words that are often found in high-level imperative or object-oriented languages.
___________________ _____________________ ______________________
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
41
Briefly describe the task of each of the following.
A.Lexical analyzer
B.Parser
C.Code Generator
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
42
Explain the distinction between fruitful and void functions.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
43
In the context of the object-oriented paradigm,what is a constructor?
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
44
Explain the distinction between a formal parameter and an actual parameter.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
45
Explain why the generation approach to classifying programming languages fails to capture the full scope of today's languages.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
46
Explain the distinction between the imperative and declarative programming paradigms.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
47
Based on the grammar below,draw a parse tree showing that the string "drip drip drip" is a Leak.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
48
Show that the grammar below is ambiguous by drawing two distinct parse trees for the string "drip drip drip."
Show that the grammar below is ambiguous by drawing two distinct parse trees for the string drip drip drip.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
49
What does it mean to say that a programming language is machine independent?
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
50
Based on the Prolog program below,what goal should be used to find the siblings of sue?
parent(jill,sue).
parent(jill,sally).
parent(john,sue).
parent(john,sally).
sibling(X,Y):- parent(Z,X),parent(Z,Y).
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
51
Explain the distinction between translating a program (in a high-level language)and interpreting the program.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
52
Explain the distinction between global and local variables.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
53
Why is the straightforward "goto" statement no longer popular in high-level programming languages?
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
54
Explain why key words in a programming language are often reserved words.
Unlock Deck
Unlock for access to all 54 flashcards in this deck.
Unlock Deck
k this deck
locked card icon
Unlock Deck
Unlock for access to all 54 flashcards in this deck.