COSC 35305

subject Type Homework Help
subject Pages 9
subject Words 1103
subject Authors Harvey Deitel, Paul J. Deitel

Unlock document.

This document is partially blurred.
Unlock all pages and 1 million more documents.
Get Access
page-pf1
Which of the following will generate an error?
(a) if (answer == 7) {
puts("correct");
}
else {
puts("incorrect");
}
(b) puts(answer == 7 ? "correct" : "incorrect");
(c) printf("%s\n", answer == 7 ? "correct" : "incorrect");
(d) answer == 7 ? puts("correct") : puts("incorrect");
Which statement about the algorithm we presented in Section 7. of the text for shuffling
a deck of cards is true?
a) It's guaranteed to terminate.
b) It could execute indefinitely.
c) It's efficient.
d) It uses a one-dimensional array of 52 cards.
page-pf2
Which of the following statements is false?
(a) A key feature of functions like printf_s and scanf_s that makes them more secure is
that they have runtime pointer constraints that are checked after attempting to use the
pointers.
(b) In a scanf_s, if any of the pointer arguments (including the format-control string) are
NULL, the function returns EOF.
(c) In a printf_s, if the format-control string or any argument that corresponds to a %s is
NULL, the function stops outputting data and returns a negative number.
(d)None of the above.
Every variable has all the attributes below, except
a) name
b) value
c) alias
d) type
Which statement about an escape sequence is false?
page-pf3
a) \r moves the cursor to the beginning of the next line.
b) \b moves the cursor back one position on the current line.
c) \f moves the cursor to the start of the next logical page.
d) \v moves the cursor to the next vertical tab position.
Which statement is true?
a) fread always reads a record at a time from a file into memory.
b) fread reads a specified number of bytes from a file into memory.
c) Every fread call must include an argument with sizeof.
d) fread reads bytes from a position in the file specified as one of fread's arguments.
Given that k is an integer array starting at location 2000, kPtr is a pointer to k, and each
integer is stored in 4 bytes of memory, what location does kPtr + 3 point to?
(a) 2003
(b) 2006
(c) 2012
page-pf4
(d) 2024
If the macro
#define RECTANGLE_AREA(x, y) ((x) * (y))
has been defined. Then the line
rectArea = RECTANGLE_AREA(a + 4, b + 7);
will be expanded to
(a) rectArea = 11;
(b) rectArea = (a + 4 * b + 7);
(c) rectArea = ((a + 4) * (b + 7));
(d) RECTANGLE_AREA(a + 4 , b + 7);
Which statement about bubble sort is true?
(a) a maximum of n passes are needed to sort the array, where n is the number of
elements
(b) swapping values requires two assignments
page-pf5
(c) performance is maximized
(d) the algorithm is very simple compared to other sorting procedures
A string array
(a) stores an actual string in each of its elements
(b) can only provide access to strings of a certain length
(c) is actually an array of pointers
(d) is always less memory efficient than an equivalent double-subscripted array
Which of the following statements is true?
(a) Allowing multiple enumeration constants to have the same value can result in
difficult-to-find logic errors.
(b) Performing bitwise operations on integer types smaller than int always yields
correct results.
(c) Bitwise operations on signed and unsigned integer types are portable across
platforms.
(d)None of the above.
page-pf6
Arrays are data structures consisting of related data items of the same __________.
a) sort order
b) subscript
c) type
d) element
Assume string1 is a character array. Which of the following operations does not
produce a string?
(a) string1[] = "test";
(b) string1[] = {'t', 'e', 's', 't', '\0'};
(c) string1[] = {'t', 'e', 's', 't'};
(d) string1[] = " ";
page-pf7
The #includepreprocessor directive causes a(n) ____________ to be included in place
of the directive.
(a) copy of a file
(b) # character
(c) pointer to a file
(d) bitfield
'\n' represents the integer value of
a) the character n
b) the string n
c) newline
d) nextline
Q3: To declare class subClass a privately derived class of superClass one would write:
a. class subclass : private superClass
page-pf8
b. class subclass :: private superClass
c. class subclass < private superClass >
d. class subclass inherits private superClass
________ models software in terms similar to those that people use to describe
real-world objects.
(a) Method-oriented programming
(b) Object-oriented design
(c) Procedural programming
(d) None of the above
Which of the following statements is true about undefined behavior, which can leave a
system open to attack?
(a) It's not possible to have undefined behavior when adding two integers.
(b) Adding two integers can result in arithmetic overflow, which can cause undefined
behavior.
(c) You should not worry about undefined behavior in your programs.
page-pf9
(d)None of the above.
Which statement is false?
a) Both recursion and iteration are based on a control statement.
b) Both iteration and recursion involve iteration.
c) Iteration with sentinel-controlled iteration and recursion each gradually approach
termination.
d) Both iteration and recursion can occur infinitely.
A programmer intentionally creates a for-loop with the following for header:
for (; ;)
The programmer's intent was most likely to create
a) a syntax error
b) an infinite loop
c) a logic error
d) a divide-by-zero error
page-pfa
Which is not a format control string flag?
a) "
b) space
c) newline
d) #
Individual records of a randomly accessed file are normally ________.
(a) fixed in length
(b) not fixed in length
(c) sorted by record key
(d) read using the fopen function
page-pfb
The __________ selection statement performs an action if a condition is true and
performs a different action if the condition is false.
a) if
b) when
c) ifelse
d) switch
What value does function mystery return when called with a value of 4?
int mystery (int number)
{
if (number <= 1) {
return 1;
}
else {
return number * mystery(number " 1);
}
}
(a) 1
(b) 24
(c) 0
page-pfc
(d) 4
Constant variables
(a) can be assigned values in executable statements
(b) do not have to be initialized when they are defined
(c) can be used to specify array sizes, thereby making programs more scalable
(d) can be used to specify array sizes, but this makes programs harder to understand
Which is not a formatting capability of printf?
a) left justification
b) centering
c) right justification
d) aligning a column of numbers so that decimal appoints appear one above the other
page-pfd
The __________ is called a multiple selection statement.
a) if
b) when
c) if else
d) switch
Which statement is false?
a) Pseudocode is an artificial and informal language that helps you develop algorithms.
b) Pseudocode is similar to everyday English.
c) Pseudocode is an actual programming language.
d) Pseudocode programs are not actually executed on computers.
Normally, statements in a program are executed one after the other in the order in which
page-pfe
they are written. This is called __________ execution.
a) inline
b) seeking
c) ordered
d) sequential
Q1: Which of the following statements about polymorphism is false?
a. With polymorphism, you can direct a variety of objects to behave in manners
appropriate to those objects without even knowing their types.
b. With polymorphism, new types of objects that can respond to existing messages can
easily be incorporated into a system without modifying the base system.
c. Polymorphism enables you to deal in specifics and let the execution-time
environment concern itself with the generalities.
d. To get polymorphic behavior among existing objects, those objects must be
instantiated from classes in the same inheritance hierarchy.
Which statement about precedence is false?
page-pff
a) Parentheses may be used to force the order of evaluation to occur in any sequence
desired by the programmer.
b) Nested, or embedded parentheses are evaluated last.
c) Multiplication has a higher precedence than addition.
d) Subtraction has a lower precedence than division.
Q2: Which of the following is not true of a destructor?
a. It performs termination housekeeping.
b. It is called before the system reclaims the object's memory.
c. If the programmer does not explicitly provide a destructor, the compiler creates an
"empty" destructor.
d. It releases the object's memory.

Trusted by Thousands of
Students

Here are what students say about us.

Copyright ©2022 All rights reserved. | CoursePaper is not sponsored or endorsed by any college or university.