Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
Download as pdf or txt
Download as pdf or txt
You are on page 1of 2

Test Ch6 (Programming Languages)

Multiple Choice Questions


1. 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++
ANSWER: A

3. Most machine languages are based on the


A. Imperative paradigm B. Declarative paradigm
C. Functional paradigm D. Object-oriented paradigm
ANSWER: A

5. Which of the following does not require a Boolean condition?


A. If- else statement B. While statement
C. Assignment statement D. For loop statement
ANSWER: C

7. Which of the following is not a loop?


A. If -else statement B. While statement
C. Repeat statement D. For statement
ANSWER: A

9. Which of the following is not associated with object-oriented programming?


A. Inheritance B. Resolution C. Encapsulation D. Polymorphism
ANSWER: B

11. Positions within arrays are identified by means of numbers called


A. Indices B. Parameters C. Instance variables D. Constants
ANSWER: A

13. Which of the following is not a possible value of the expression 4 + 6  2 - 1


A. 4 B. 5 C. 6 D. 10
ANSWER: B

15. 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
ANSWER: B

17. Which of the following is not constructed by a typical compiler?


A. Source code B. Symbol table C. Parse tree D. Object program
ANSWER: A

21. 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)
ANSWER: C
General Format Questions
1. What does it mean to say that a programming language is machine independent?
ANSWER: It means that programs written in the language do not refer to properties of a specific machine and
are therefore compatible with any computer.

3. Explain data abstraction.


ANSWER: Data abstraction provides a means of separating behavior from implementation. In object-oriented
programming, encapsulation facilitates data abstraction.

5. Why is the straightforward “goto” statement no longer popular in high-level programming languages?
ANSWER: Its use led to poorly structured programs that were hard to understand.

7. Explain the distinction between global and local variables.


ANSWER: A global variable is readily accessible throughout the program whereas a local variable is accessible
only within a specific area.

9. Based on the grammar below, draw a parse tree showing that the string “drip drip drip” is a Leak.

ANSWER:

11. In the context of the object-oriented paradigm, what is a constructor?


ANSWER: A constructor is a special “method” that is executed when an object is first constructed, normally for
the purpose of performing initialization activities.

13. In the object-oriented paradigm, what are methods and instance variables.
ANSWER: A variable that resides within an object is called an instance variable. A function that resides within
an object is called a method.

You might also like