Chapter 1 - Software Engineering Principles and Java Classes

TRUE/FALSE

	1.	A program goes through many phases from the time it is first conceived until the time it is retired, called the life cycle of the program.

ANS:	T	REF:	2

	2.	The three fundamental stages a program goes through are: implementation, use, and maintenance.

ANS:	F	REF:	2

	3.	In the software development process, the program is modified to fix the (identified) problems or to enhance it.

ANS:	F	REF:	2

	4.	A program that is well developed is difficult and more expensive to maintain.

ANS:	F	REF:	2

	5.	Software engineers typically break the software development process into the following four phases: analysis, design, implementation, testing, and debugging.

ANS:	T	REF:	2

	6.	An algorithm is a step-by-step problem-solving process in which a solution is arrived at in a finite amount of time.

ANS:	T	REF:	3

	7.	The structured design approach is also known as modular programming.

ANS:	T	REF:	3

	8.	Encapsulation is the ability to handle data and operations as separate units.

ANS:	F	REF:	4

	9.	In OOP, each object consists of data and operations on those data.

ANS:	T	REF:	4

	10.	OOD has the three basic principles: encapsulation, inheritance, and polymorphism.

ANS:	T	REF:	4

	11.	Encapsulation is the ability to create new data types from existing data types.

ANS:	F	REF:	4

	12.	Polymorphism is the ability to use the same expression to denote different operations.

ANS:	T	REF:	4

	13.	A precondition is a statement specifying the condition(s) that must be true before the function is called.

ANS:	T	REF:	5

	14.	A postcondition is a statement specifying what is true before the function call is completed.

ANS:	F	REF:	5

	15.	In black-box testing, the internal workings of the algorithm or function are known.

ANS:	F	REF:	7

	16.	The components of a class are called the objects.

ANS:	F	REF:	15

	17.	White-box testing relies on the internal structure and implementation of a function or algorithm.

ANS:	T	REF:	7

	18.	The term asymptotic means the study of the function f as n becomes larger and larger without bound.

ANS:	T	REF:	14

	19.	If g(n) = 1, the growth rate is constant and does not depend on the size of the problem.

ANS:	T	REF:	15

	20.	In Java, the mechanism that allows you to combine data and the operations on that data in a single unit is called a class.

ANS:	T	REF:	15

	21.	The members of a class are classified into three categories: private, public, and main.

ANS:	F	REF:	16

	22.	Private, public, and protected are modifiers in Java.

ANS:	T	REF:	16

	23.	A class and its members can be described graphically using a notation known as United Modeling Language (UML) notation.

ANS:	F	REF:	19

	24.	Finalizers are value-returning methods that return the final value of a variable.

ANS:	F	REF:	40

	25.	When no object of the class type is instantiated, static data members of the class fail to exist.

ANS:	F	REF:	39

MULTIPLE CHOICE

	1.	The three fundamental stages a program goes through are: development, use, and ____.
a.	implementation	c.	analysis	
b.	maintenance	d.	requirements gathering	

ANS:	B	REF:	2

	2.	In the ____ process, the program is modified to fix the (identified) problems or to enhance it.
a.	software life cycle	c.	software maintenance	
b.	implementation	d.	testing	

ANS:	C	REF:	2

	3.	Software engineers typically break the software development process into the following four phases: analysis, ____, implementation, testing and debugging.
a.	design	c.	white box analysis	
b.	requirements gathering	d.	algorithm analysis	

ANS:	A	REF:	2

	4.	A(n) ____ is a step-by-step problem-solving process in which a solution is arrived at in a finite amount of time.
a.	design plan	c.	process plan	
b.	algorithm	d.	structured program	

ANS:	B	REF:	3

	5.	The structured design approach is also known as ____.
a.	top down design	c.	modular programming	
b.	stepwise refinement	d.	All of the above	

ANS:	D	REF:	3

	6.	____ is the ability to create new data types from existing data types.
a.	Encapsulation	c.	Inheritance	
b.	Overloading	d.	Polymorphism	

ANS:	C	REF:	4

	7.	____ is the ability to use the same expression to denote different operations.
a.	Overloading operators	c.	Inheritance	
b.	Polymorphism	d.	Encapsulation	

ANS:	B	REF:	4

	8.	A(n) ____ is a statement specifying the condition(s) that must be true before the function is called.
a.	precondition	c.	declaration	
b.	postcondition	d.	algorithm	

ANS:	A	REF:	5

	9.	Which of the following functions g(n) has the fastest growth rate (for n > 1)?
a.	n	c.	n log n	
b.	n2	d.	1	

ANS:	B	REF:	15

	10.	Which of the following functions g(n) has the slowest growth rate (for n > 1)?
a.	n	c.	n log n	
b.	n2	d.	1	

ANS:	D	REF:	15

	11.	Which of the following functions g(n) has a constant growth rate?
a.	n	c.	n log n	
b.	n2	d.	1	

ANS:	D	REF:	15

	12.	In Java, the mechanism that allows you to combine data and the operations on that data in a single unit is called a(n) ____.
a.	object	c.	class	
b.	member	d.	friend	

ANS:	C	REF:	15

	13.	The components of a class are called the ____ of the class.
a.	members	c.	functions	
b.	objects	d.	variables	

ANS:	A	REF:	15

	14.	Which of the following categorizes a member of a class?
a.	private	c.	safe	
b.	open	d.	static	

ANS:	A	REF:	16

clockType
------------
-hr: int
-min: int
-sec: int
----------------------------------------
+setTime (int, int, int): void
+getTime (int&, int&, int&): void
+printTime (): void
+incrementSeconds (): int
+incrementMinutes (): int
+incrementHours (): int
+equalTime (const clockType&): bool

	15.	In the code above, the top portion contains the ____.
a.	name of the class	c.	methods	
b.	members	d.	variables	

ANS:	A	REF:	20

	16.	In the code above, the middle portion contains the ____.
a.	member methods	c.	data members and data types	
b.	class constructors	d.	class destructor	

ANS:	C	REF:	20

	17.	In the code above, the bottom portion contains the ____, parameter list, and the return type of the function.
a.	name of the class	c.	constants	
b.	name of the member methods	d.	destructor	

ANS:	B	REF:	20

	18.	The ____ of a class serves to initialize its variables.
a.	helper method	c.	destructor	
b.	constructor	d.	prototype	

ANS:	B	REF:	18

	19.	A(n) ____ is a data type that specifies the logical properties without the implementation details.
a.	public	c.	private	
b.	protected	d.	abstract data type	

ANS:	D	REF:	47

public Clock()
{
	setTime(0, 0, 0);
}

	20.	What is the name of the class that the constructor above belongs to?
a.	Clock	
b.	public	
c.	setTime	
d.	It cannot be determined from the information given.	

ANS:	A	REF:	19

	21.	In ____ copying, each reference variable refers to its own object.
a.	shallow	c.	method	
b.	deep	d.	object	

ANS:	B	REF:	26

	22.	How many finalizers can a class have?
a.	0	c.	2	
b.	1	d.	Any number	

ANS:	B	REF:	40

	23.	Which of the following would be appropriate syntax for the heading of a copy constructor for a class called Ruler?
a.	public Ruler(int inches, int centimeters)	
b.	public Ruler()	
c.	public Ruler(Ruler myRuler)	
d.	public copyRuler(int inches, int centimeters)	

ANS:	C	REF:	35