- Which of the following is an example of a language that is based on the functional paradigm?
- LISP B. PROLOG C. C D. C++
ANSWER: A
- Which of the following is an example of a language that is based on the object-oriented paradigm?
- LISP B. PROLOG C. C D. C++
ANSWER: D
- Most machine languages are based on the
- Imperative paradigm B. Declarative paradigm
- Functional paradigm D. Object-oriented paradigm
ANSWER: A
- Which of the following is not a type of statement found in a typical high-level imperative programming language?
- Imperative statement B. Exclamatory statement
- Declarative statement D. Comment statement
ANSWER: B
- Which of the following does not require a Boolean structure?
- If-then-else statement B. While loop statement
- Assignment statement D. For loop statement
ANSWER: C
- Which of the following is not a control statement?
- If-then-else statement B. While loop statement
- Assignment statement D. For loop statement
ANSWER: C
- Which of the following is not a control statement?
- If-then-else statement B. While loop statement
- Assignment statement D. For loop statement
ANSWER: C
- Which of the following is not a step in the process of translating a program?
- Executing the program B. Parsing the program
- Lexical analysis D. Code generation
ANSWER: A
- Which of the following is not associated with object-oriented programming?
- Inheritance B. Resolution C. Encapsulation D. Polymorphism
ANSWER: B
- Which of the following is not associated with the concept of data type?
- Coercion B. Boolean C. Operator precedence D. Strongly typed language
ANSWER: C
- Positions within arrays are identified by means of numbers called
- Indices B. Parameters C. Instance variables D. Constants
ANSWER: A
- Which of the following is ignored by a compiler?
- Control statements B. Declarations of constants
- Procedure headers D. Comment statements
ANSWER: D
- Which of the following is not a possible value of the expression 4 + 6 ¸ 2 – 1
- 4 B. 5 C. 6 D. 10
ANSWER: B
- Which of the following is not a way of referring to a value in a program?
- Variable B. Literal C. Constant D. Type
ANSWER: D
- Which of the following is the scope of a variable?
- The number of characters in the variable’s name
- The portion of the program in which the variable can be accessed
- The type associated with the variable
- The structure associated with the variable
ANSWER: B
- Which of the following is a means of nullifying conflicts among data types?
- Inheritance B. Parsing C. Coercion D. Code optimization
ANSWER: C
- Which of the following is not constructed by a typical compiler?
- Source code B. Symbol table C. Parse tree D. Object program
ANSWER: A
- Which of the following is a means of defining similar yet different classes in an object-oriented program?
- Inheritance B. Parsing C. Coercion D. Code optimization
ANSWER: A
- Which of the following is not a parse tree of an expression based on the following grammar?
- B. C.
ANSWER: C
- 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
- Q OR ØR OR T B. T OR P C. P OR ØR OR T D. Q OR T
ANSWER: B
- 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).
- parent(jill, john) B. sister(sue, sally)
- sibling(sue, sally) D. sibling(jill, sue)
ANSWER: C
Fill-in-the-blank/Short-answer Questions
- In contrast to _______________ languages such as English and Spanish, programming languages are
considered _______________ languages and are rigorously defined by their grammars.
ANSWER: natural, formal
- List two disadvantages of both machine languages and assembly languages that are overcome by high-level programming languages.
_____________________________________
_____________________________________
ANSWER: They are machine dependent and they require that algorithms be expressed in small machine-related steps rather that larger application-oriented steps.
- Indicate how each of the following types of programming languages is classified in terms of generation (first generation, second generation, or third generation).
- High-level languages _____________
- Machine languages _____________
- Assembly languages _____________
ANSWER: A. Third generation B. First generation C. Second generation
- List four data types that occur as primitive types in many high-level programming languages.
____________________ ____________________
____________________ ____________________
ANSWER: Possible answers include: integer, real (or float), Boolean, and character.
- What encoding system is commonly used to encode data of each of the following types?
- Integer ___________________________
- Real __________________________
- Character ___________________________
ANSWER: (CAUTION: This question relies on material from chapter 1)
- Two’s complement
- Floating-point
- ASCII or Unicode
- A data structure in which all elements have the same type is called ___________________, whereas a ________________ may have elements of different types.
ANSWER: an array; record, structure or heterogeneous array
- In programming languages that use + to mean concatenation of character strings, the expression
“2x” + “3x”
will produce what result?
________________
ANSWER: “2x3x”
- Rewrite the following instructions using a single if-then-else statement.
if (X = 5) goto 50
goto 60
50 print the value of Z
goto 100
60 print the value of Y
100 . . .
ANSWER: if (X = 5) then (print the value of Z) else (print the value of Y)
- The following is a program segment and the definition of a procedure named sub.
.
.
X ¬ 3; procedure sub (Y)
sub (X); Y ¬ 5;
print the value of X;
.
.
- What value will be printed by the program segment if parameters are passed by value?
____________
- What value will be printed by the program segment if parameters are passed by reference?
____________
ANSWER: A. 3 B. 5
- The following is a program segment and the definition of a procedure named sub.
. procedure sub
. .
X ¬ 8; .
apply procedure sub; X ¬ 2;
print the value of X; .
. .
.
- What value will be printed by the program segment if X is a global variable?
____________
- What value will be printed by the program segment if X is a declared as a local variable
within the procedure?
____________
ANSWER: A. 8 B. 2
- To say that a grammar is ambiguous means that ___________________________________________
_____________________________________________________________________ .
ANSWER: the grammar allows more than one parse tree for a single string
- List three items of information that would be contained in a typical parser’s symbol table.
________________________
________________________
________________________
ANSWER: Possible answers include: names of variables, data types associated with variables, data structures associated with variables, and others.
- Give three examples of key words that are often found in high-level imperative or object-oriented languages.
___________________ _____________________ ______________________
ANSWER: Possible answers are numerous and include: if, while, for, class, int, etc.
- In addition to the procedure’s name, what other information is contained in a typical procedure header?
____________________________________
ANSWER: A list of the formal parameters
- 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.
ANSWER: classes, objects
- 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.
ANSWER: method (or member function for C++ programmers)
- 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( )
{ . . .}
}
_________________________________________________________
ANSWER: method1 and method3
- What clause would produce the resolvent
P OR R OR S
when resolved with the clause
P OR ØQ
__________________
ANSWER: Q OR R OR S
- 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).
___________________________________________________________
ANSWER: The equivalent of: better(X, Z) :- better(X, Y), better(Y, Z).
- 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).
_________________________________________
ANSWER: Either sibling(X, sue) or sibling(sue, X)
Vocabulary (Matching) Questions
The following is a list of terms from the chapter along with descriptive phrases that can be used to produce questions (depending on the topics covered in your course) in which the students are ask to match phrases and terms. An example would be a question of the form, “In the blank next to each phrase, write the term from the following list that is best described by the phrase.”
Term Descriptive Phrase
assembly language A step up from machine language
programming paradigm A program development methodology
structured programming A methodology that applies well-designed control structures to
produce well-organized software
grammar The rules defining the syntax of a programming language
parse tree A “pictorial” representation of the grammatical structure of a string
compiler A program that translates other programs into machine language
interpreter A program that executes other programs written in a high-level
language without first translating them into machine language
high-level language A notational system for representing algorithms in human compatible
terms rather than in the details of machinery
semantics Meaning as opposed to appearance
syntax Appearance as opposed to meaning
operator precedence Dictates the order in which operations are performed
data structure A conceptual organization of information
parameter A means of passing information to a procedure or function
data type Encompasses both an encoding system and a collection of operations
syntax diagrams A way of representing a grammar
source program A program expressed in a high-level language
General Format Questions
- 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.
- Explain the distinction between the imperative and declarative programming paradigms.
ANSWER: The imperative paradigm requires that a programmer describe an algorithm for solving the problem at hand. The declarative paradigm requires that the programmer describe the problem.
- Explain why the generation approach to classifying programming languages fails to capture the full scope of today’s languages.
ANSWER: The generation approach fails to reflect the array of distinct programming paradigms.
- Explain the distinction between translating a program (in a high-level language) and interpreting the program.
ANSWER: To translate a program is to convert it to another (usually low-level) language without executing it. To interpret a program is to execute it directly from its high-level language form.
- 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.
- Explain the distinction between a formal parameter and an actual parameter.
ANSWER: A formal parameter is a term used in a subprogram unit to refer to data that will be given to the subprogram when it is executed. An actual parameter is the data that is given to the subprogram unit when it is executed. (A formal parameter is a “place holder” that is “filled in” with an actual parameter when the subprogram unit is executed.)
- 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.
- Explain the distinction between a procedure and a function.
ANSWER: A procedure returns values via parameters and global variables whereas a function returns a value as “the value of the function.”
- Based on the grammar below, draw a parse tree showing that the string “drip drip drip” is a Leak.
ANSWER:
- Show that the grammar below is ambiguous by drawing two distinct parse trees for the string “drip drip drip.”
ANSWER: Possible answers include:
- 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.
- Briefly describe the task of each of the following.
- Lexical analyzer
- Parser
- Code Generator
ANSWER: A. Groups symbols together to form tokens
- Ascertains the grammatical role of program’s components
- Constructs object program
- Explain why key words in a programming language are often reserved words.
ANSWER: Key words are used to help the parser identify grammatical structures in a program. Thus, using these words are used for other purposes could confuse the parser.
Test Bank—Chapter Seven (Software Engineering)
Multiple Choice Questions
- Which of the following software engineering methodologies is the most rigid?
- Incremental model B. Waterfall model
- Extreme programming D. Evolutionary prototyping
ANSWER: B
- Which of the following is a notational system for representing object-oriented designs?
- UML B. Structure charts C. Modular designs D. Dataflow diagrams
ANSWER: A
- Which of the following is an attempt to construct software from off-the-shelf components as is done in other engineering fields?
- Extreme programming B. Evolutionary prototyping
- Component architecture D. Open-source development
ANSWER: C
- Which of the following is most likely an example of a one-to-one relationship?
- Subscribers and magazines B. Birth dates and people
- Planets and their moons D. Dinner guests and table settings
ANSWER: D
- Which of the following is most likely an example of a many-to-many relationship?
- Subscribers and magazines B. Birth dates and people
- Planets and their moons D. Dinner guests and table settings
ANSWER: A
- Which of the following is not a feature of UML?
- Use case diagrams B. Class diagrams
- Dataflow diagrams D. Sequence diagrams
ANSWER: C
- The use of design patterns in software engineering was adopted from what other field?
- Business administration B. Architecture
- Biology D. Chemistry
ANSWER: B
- Which of the following is a form of glass-box testing?
- Basis path testing B. Boundary value analysis C. Beta testing
ANSWER: A
- Which of the following is a means of controlling the complexity of a software system?
- CRC cards B. Modularity C. Specifications D. Beta testing
ANSWER: B
- Which of the following is a way of testing the design of a software system?
- Entity-relationship diagram B. Class diagram
- Structure chart D. Structured walkthrough
ANSWER: D
- Which of the following is not related to the others?
- Structure chart B. Imperative paradigm
- Class diagram D. Procedure
ANSWER: C
- Which of the following is the method proposed by UML for representing sequences of communication between objects?
- Class diagram B. Use case diagram
- Sequence diagram D. Generalization
ANSWER: C
- Which of the following is not represented in a class diagram?
- Generalizations B. The methods within a class
- The attributes within a class D. The number of instances each class will have
ANSWER: D
- Which of the following is least related to the Pareto principle?
- When it rains, it pours.
- Birds of a feather flock together.
- Better late than never.
ANSWER: C
- The Pareto principle is traditionally applied during which phase of software development?
- Requirements Analysis B. Design
- Implementation D. Testing
ANSWER: D
- Which of the following is the oldest approach to software development?
- Component architecture B. Waterfall model
- Open-source development D. Extreme programming
ANSWER: B
- Which of the following is not a tool for designing modular systems?
- Structure charts B. Data dictionaries
- Class diagrams D. Sequence diagrams
ANSWER: B
- Which of the following is a stronger form of cohesion?
- Functional cohesion B. Logical cohesion
ANSWER: A
- Which of the following appears to be the most functionally cohesive?
- A module that handles all of a customers banking needs
- A module that handles only transactions related to checking accounts
- A module that only records deposits to checking accounts
- A module that collects data for monthly statements
ANSWER: C
- If a class diagram indicates a one-to-one relationship between class X and class Y, then
- there will be only one object in the system of “type” X.
- each object of “type” X will be associated with only one object of “type” Y.
- there will be exactly one object of “type” X and exactly one object of “type” Y.
- an object of “type” Y cannot occur without first constructing an object of “type” X.
ANSWER: B
- Copyright laws were established
- to allow authors to distribute their work while maintaining certain ownership rights.
- to allow authors to maintain ownership of their ideas.
- to restrict access to publications to certain groups within society.
- to allow ideas to be traced back to their origins.
ANSWER: A
Fill-in-the-blank/Short-answer Questions
- Identify the stage of software development in which each of the following activities is performed.
- _____________________ Programming is conducted.
- _____________________ Class diagrams are drawn.
- _____________________ User needs are analyzed.
ANSWER: A. Implementation B. Design C. Requirements Analysis
- Requirements analysis provides a __________________ of a proposed software product whereby the user needs, features, and services are identified and recorded in a document called a ________________ .
ANSWER: description, software requirements specification
- Prototyping occurs in two forms. In one, called __________________ prototyping the original
prototype is slowly enhanced to become the final product. In the other, called _______________
prototyping, the original prototype is used as an “experimental” system that is ultimately discarded.
ANSWER: Evolutionary, throwaway
- Answer the following questions in terms of the structure chart below.
- What modules directly use the services of module E?
____________
- The services of which modules are directly used by module A?
____________
ANSWER: A. C and D B. B, C, and D
- Based on the structure chart below, in which module does the data item w originate?
____________
ANSWER: B
- In an object-oriented design using UML, __________ diagrams are used to represent classes and their
basic relationships, whereas _____________ diagrams are used to represent communication between
objects.
ANSWER: Class, sequence
- In each of the following, indicate whether the information would be represented within a use case diagram, a class diagram, or a sequence diagram.
- __________________ The methods within a class
- __________________ The ways in which the system will interact with its environment
- __________________ The manner in which its internal objects will interact
- __________________ Relationships among classes
ANSWER: A. Class diagram B. Use case diagram C. Sequence diagram D. Class diagram
- ____________ is a notational system for representing object-oriented designs. It includes standards for
representing _______________ diagrams that show how users interact with the proposed system as well
as ______________diagrams that show how objects within the proposed system will interact.
ANSWER: UML, use case, sequence
- Give an example of a one-to-many relationship.
____________________________________________________________
ANSWER: Answers may vary. Examples include: classrooms to chairs (a classroom has many chairs but each chair is in only one classroom), mothers to children (a mother may have many children but each child has only one mother), and many others.
- In each case below indicate whether the activity relates to a structure chart or a class diagram.
- ___________________ Identifying actions to be performed
- ___________________ Identifying the types of objects in a system
- ___________________ Identifying relationships between “types” of objects
- ___________________ Identifying how activities performed by different procedures relate to
one another
ANSWER: A. Structure chart B. Class diagram C. Class diagram D. Structure chart
- In each case below indicate whether the activity relates to a sequence diagram or a dataflow diagram.
- ___________________ Identifying messages passed between objects
- ___________________ Identifying how data items are combined to produce new items
- ___________________ Identifying how tasks are performed via object interactions
- ___________________ Identifying how information and leaves a system
ANSWER: A. Sequence diagram B. Dataflow diagram C. Sequence diagram D. Dataflow diagram
- In each case below indicate whether the phrase relates to coupling or cohesion.
- ___________________ The interaction between modules
- ___________________ Passing data from one module to another
- ___________________ Ensuring that a module performs a unique task in its entirety
ANSWER: A. Coupling B. Coupling C. Cohesion
- Identify two forms of inter-module coupling.
______________________
______________________
ANSWER: Data coupling and control coupling
- In each case below indicate whether the activity is a form of glass-box testing or black-box testing.
- ___________________ Basis path testing
- ___________________ Boundary value analysis
- ___________________ Beta testing
ANSWER: A. Glass-box testing B. Black-box testing C. Black-box testing
- In each case below indicate whether the activity relates to glass-box testing or black-box testing.
- ___________________ Testing to see if the system performs in a timely manner
- ___________________ Designing test data to ensure that each instruction is executed at least
once
- ___________________ Testing to see if the software system meets the requirements
identified during original analysis
ANSWER: A. Black-box testing B. Glass-box testing C. Black-box testing
- State the Pareto principle in the context of software engineering.
__________________________________________________________________________
ANSWER: Errors in a software system tend to be concentrated in relatively small areas.
- In each case below indicate whether the activity is primarily top-down or bottom-up.
- ___________________ Building software from previously constructed components
- ___________________ Dividing a module into smaller modules to obtain greater cohesion
- ___________________ Designing a dataflow diagram by successively adding more
specificity
ANSWER: A. Bottom-up B. Top-down C. Top-down
- As a general rule, one should strive to ____________________ (maximize or minimize) coupling
between modules and to ____________________ (maximize or minimize) cohesion within modules.
ANSWER: minimize, maximize
- Give two examples of recent advances in software engineering.
_____________________
_____________________
ANSWER: There are many possible answers (and they vary depending on the interpretation of “recent.” Answers include: component architecture, the application of design patterns, open-source development, extreme programming, the use of prototypes, CASE tools, the development of UML, and others.
- Identify two legal techniques that have been applied to protect a software developer’s ownership rights.
_____________________
_____________________
ANSWER: Possible answers include copyright law, patent law, and software licenses.
Vocabulary (Matching) Questions
The following is a list of terms from the chapter along with descriptive phrases that can be used to produce questions (depending on the topics covered in your course) in which the students are ask to match phrases and terms. An example would be a question of the form, “In the blank next to each phrase, write the term from the following list that is best described by the phrase.”
Term Descriptive Phrase
metric A means of quantifying
software life cycle Develop, use, modify
waterfall model An older, rather rigid approach to software development
prototyping An approach to software development in which partial systems are
constructed
component architecture A means of constructing software from prefabricated units
design The software development phase which defines “how” the system will be built.
structure chart A means of representing procedural dependencies
cohesion The “glue” that holds a module together
sequence diagram A diagram representing communication between objects
use case diagram A diagram representing communication between a system and its users
UML A standard notational system for representing object-oriented designs
extreme programming Develops software incrementally by means of repeated daily cycles of informal requirements analysis, designing, implementing, and testing
global data A means of implementing implicit coupling
modularity A means of managing complexity within a large software system
structured walkthrough A means of testing a design before it is implemented
incremental model An approach to software development that first builds a simplified version of the product and then add features in a stepwise manner
beta testing Allows potential users to experiment with preliminary versions of
software
glass-box testing Confirms that the internal structure of a software system is reliable
open-source development A somewhat renegade methodology for software development
requirements analysis The software development phase which defines “what” the system is to do
data dictionary A central warehouse of information regarding data throughout a
system
top-down General to specific (as opposed to specific to general)
one-to-many A type of relationship between entities
implementation The software development phase that involves writing programs.
General Format Questions
- Identify two distinctions between software engineering and other traditional fields of engineering.
ANSWER: Possible answers include: In contrast to traditional fields of engineering, there is a lack of metrics for measuring quantities in software engineering. Software engineering does not involve tolerances in the sense of traditional engineering. Traditional engineering builds products from off-the-shelf components; this is still a goal in software engineering.
- In what sense is the software life cycle different from the life cycle of other products?
ANSWER: Software does not wear out so rather than needing maintenance in the traditional sense, software requires modification due to changing environments or detection of errors.
- Explain the distinction between open-source development and beta testing.
ANSWER: Open-source development involves “testers” to modify software whereas beta testing allows them only to report errors.
- Describe the data coupling represented by the following structure chart.
ANSWER: The modules B, A, D, and E are coupled via the data item w. B creates w and passes it to A, A passes it to D, and D passes it to E.
- Describe the control coupling represented by the following structure chart.
ANSWER: Module A can pass control to modules B, C, and D. Each of modules C and D can pass control to E.
- Describe the process of a structured walkthrough.
ANSWER: A structured walkthrough is a “theatrical” exercise in which people play the roles of various software modules in order to identify flaws in the system’s design.
- In what sense is the object-oriented paradigm ideal for implementing design patterns?
ANSWER: The object-oriented paradigm uses classes as templates for constructing objects. This “template” approach is a natural means of implementing design patterns.
- Give an argument supporting the statement that modularity is the most important principle in software engineering.
ANSWER: Modularity, which is found in all software engineering paradigms, is the primary means of dealing with complexity.
- Explain the distinction between structure charts and class diagrams.
ANSWER: The two are used in different design paradigms. Structure charts are used to represent the relationship between procedural modules in an imperative design. Class diagrams are used to represent the relationship between classes in an object-oriented design.
- Explain some of the ways in which software engineering has benefited from the development of the object-oriented paradigm.
ANSWER: The concept of classes and objects provides an excellent modularizing tool. Moreover, it has provided a means of implementing design patterns so that software can be constructed from prefabricated components.
- Explain the role of each of the following forms of documentation: user documentation, technical documentation, and system documentation.
ANSWER: User documentation explains how to use a system as an abstract tool. Technical documentation explains how to install a system, how to update the system, and perhaps how to customize the system. System documentation explains the internal construction of the system to support internal modifications.
- Explain why inheritance may not be the best way of implementing generalizations among classes.
ANSWER: Inheritance introduces a strong coupling between classes that may cease to be valid in later software modifications.
- For the following class diagram:
- What kind of relationship is noted between Customer and Account? __________
- What kind of relationship is noted between Bank and Account? __________
- What kind of relationship is noted between Checking and Account? __________
- What are the instance variables of Account? __________
- What are the instance variables of Checking? __________
- What are the methods of Savings? __________
- What instance variable could be added to Customer? __________
ANSWER: A. Many-to-many
- One-to-many
- Any of: inheritance, specialization/generalization, or subclass/superclass
- acctNo and balance
- checkFee, acctNo, and balance
- accrueInterest, deposit, and withdraw
- Answers can vary; name, address, and socialSecurity are valid possibilities