Accounting
Anthropology
Archaeology
Art History
Banking
Biology & Life Science
Business
Business Communication
Business Development
Business Ethics
Business Law
Chemistry
Communication
Computer Science
Counseling
Criminal Law
Curriculum & Instruction
Design
Earth Science
Economic
Education
Engineering
Finance
History & Theory
Humanities
Human Resource
International Business
Investments & Securities
Journalism
Law
Management
Marketing
Medicine
Medicine & Health Science
Nursing
Philosophy
Physic
Psychology
Real Estate
Science
Social Science
Sociology
Special Education
Speech
Visual Arts
Programming Language
Q:
Which statement is false?
a) Arrays are normally stored contiguously in memory.
b) Dynamic memory allocation can sometimes use memory more efficiently than using fixed-size data structures.
c) Dynamic memory allocation incurs execution-time overhead.
d) Linked lists are normally stored contiguously in memory.
Q:
Which of the following is false?
a) Arrays can be maintained in sorted order.
b) Linked lists can be maintained in sorted order.
c) Insertion and deletion in a sorted array (while maintaining sorted order) is efficient.
d) Once the insertion point or the node to be deleted has been located, insertion or deletion in a sorted linked list (while maintaining sorted order) is efficient.
Q:
Which of the following is false?
a) Lists of data can be stored in arrays.
b) The length of a linked list can vary dynamically.
c) Arrays can become full.
d) Linked lists cannot become full.
Q:
Which of the following is a non-linear data structure?
a) linked list
b) queue
c) binary tree
d) stack
Q:
A linked list is a __________ collection of self-referential structures, called nodes, connected by pointer links.
a) hierachical
b) linear
c) branching
d) constant
Q:
How many pointers are contained in a circular, doubly linked list with five nodes?
(a) 5
(b) 8
(c) 15
(d) 10
Q:
For a non-empty linked list, select the code that should appear in a function that adds a node to the end of the list. newPtris a pointer to the new node to be added, and lastPtris a pointer to the current last node. Each node contains a pointer nextPtr, a link to a node.
(a)
lastPtr->nextPtr = newPtr;
lastPtr = newPtr;
(b)
lastPtr = newPtr;
lastPtr->nextPtr = newPtr;
(c)
newPtr->nextPtr = lastPtr;
lastPtr = newPtr;
(d)
lastPtr = newPtr;
newPtr->nextPtr = lastPtr;
Q:
__________ is not an advantage of linked lists when compared to arrays.
(a) Dynamic memory allocation
(b) Efficient insertion and deletion
(c) Direct access to any list element
(d) Efficient use of memory
Q:
Which of these is not a common programming error?
a) Referring to memory that has been freed.
b) Freeing memory (with free) that was not dynamically allocated.
c) Assuming that the size of a structure is simply the sum of the sizes of its members.
d) Calling malloc in a statement without using sizeof.
Q:
When memory allocated with malloc is no longer needed, return that memory to the system immediately with __________.
a) free_memory
b) free_storage
c) return
d) free
Q:
Not returning dynamically allocated memory when it is no longer needed can cause a system to run out of memory prematurely. This is called a(n) __________.
a) outage
b) memory hole
c) memory access violation
d) memory leak
Q:
Which is correct?
a) Use the size operator to determine the size of a structure.
b) Use the struct size operator to determine the size of a structure.
c) Use the sizeof operator to determine the size of a structure.
d) Determine the size of a structure manually by carefully adding up the sizes of the members.
Q:
Which of the following statements is true?
a) A structure's size is sometimes smaller than the total of the sizes of its members.
b) A structure's size is always larger than the total of the sizes of its members.
c) A structure's size is not necessarily the sum of the sizes of its members.
d) A structure's size is the sum of the sizes of its members.
Q:
If no memory is available mallocreturns a(n) __________ pointer.
a) self
b) NULL
c) void
d) empty
Q:
Function malloc takes as an argument the number of bytes to be allocated, and returns a pointer of type __________ to the allocated memory.
a) char *
b) int *
c) void *
d) NULL *
Q:
__________ memory allocation is the ability for a program to obtain more memory space at execution time and to release space no longer needed.
a) Static
b) Active
c) Selective
d) Dynamic
Q:
A __________ occurs when dynamically allocated memory is not returned when it's no longer needed.
(a) memory leak
(b) self-referential error
(c) allocation error
(d) sizeoferror
Q:
A(n) __________ pointer normally indicates the end of a data structure.
a) uninitialized
b) NULL
c) self
d) dereferenced
Q:
A self-referential structure contains a ________ member that points to ________.
(a) integer, a structure of the same structure type
(b) pointer, an integer
(c) integer, an integer
(d) pointer, a structure of the same structure type
Q:
__________ facilitate high-speed searching and sorting of data, efficient elimination of duplicate items and compiling expressions into machine language.
a) Linked lists
b) Queues
c) Stacks
d) Binary Trees
Q:
__________ represent waiting lines; insertions are made at the back (also called the tail) and deletions are made from the front (also called the head) of a __________.
a) Linked lists, linked list
b) Queues, queue
c) Stacks, stack
d) Binary trees, binary tree
Q:
__________ are important in compilers and operating systemsinsertions and deletions are made only at one end of a __________its top.
a) Linked lists, linked list
b) Queues, queue
c) Stacks, stack
d) Binary trees, binary tree
Q:
__________ are collections of data items "lined up in a row"insertions and deletions are made anywhere in a __________.
a) Linked lists, linked list
b) Queues, queue
c) Stacks, stack
d) Binary trees, binary tree
Q:
Which of the following statements is true?
(a) Files written in binary format are always portable.
(b) C11's new exclusive mode allows fopen to open a file only if it does not already exist.
(c) All platforms allow you to open an unlimited number of files.
(d)None of the above
Q:
In the statement
fseek (fPtr, (account " 1) * sizeof(struct clientData), SEEK_SET);
why are we adjusting account by "1?
a) Because the account numbers start at 0 and the file starts at position 0.
b) Because the account numbers start at 0 and the file starts at position 1.
c) Because the account numbers start at 1 and the file starts at position 0.
d) Because the account numbers start at 1 and the file starts at position 1.
Q:
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.
Q:
Which of the following is a function that reads a specified number of bytes from a file into memory?
(a) fseek
(b) fwrite
(c) fread
(d) fopen
Q:
The symbolic constant __________ indicates that the file position pointer is to be positioned relative to the beginning of the file by the amount of the offset.
a) SEEK_SET
b) SEEK_BEGIN
c) SEEK_START
d) SEEK_CUR
Q:
Which statement is true?
a) fseek searches for a record by its record key.
b) fseek sets the file position pointer to a specific byte location in the file.
c) fseek moves the read-write head on the disk to the location on disk that corresponds to a specific location in a file.
d) fseek must immediately follow each call to fread or fwrite.
Q:
Which of the following is an argument of the fseek function that can have the values SEEK_SET,
SEEK_CUR or SEEK_END?
(a) stream
(b) offset
(c) whence
(d) none of these
Q:
sizeof
a) is a compile-time function
b) is a compile-time unary operator
c) is a run-time unary operator
d) is a run-time function
Q:
Which statement is true?
a) Random access file-processing programs typically read and write one field at a time.
b) Random access file-processing programs typically read and write one struct at a time.
c) The sizeof operator is a run-time unary operator that returns the size in bytes of its operand.
d) The expression sizeof(int) always returns 4.
Q:
fread and fwrite
a) can not read and write arrays of data
b) process all their data in human readable format
c) process all their data in the same format used by fscanf and fprintf, respectively
d) process all their data in "raw data" format
Q:
Function fwrite __________.
a) is equivalent to function fprintf
b) transfers a specified number of bytes beginning at a specified location in memory to a location in a file indicated by the file position pointer
c) transfers a specified number of bytes beginning at a specified location in memory to a location in a file indicated by one of its arguments
d) is equivalent to function fprintf, except that fwrite can only write to standard streams
Q:
What is the significance of the 1 in the following statement?
fwrite(&number, sizeof(int), 1, fPtr);
(a) It specifies that the file is to be opened for updating.
(b) It specifies the number of elements in the array that should be written to disk.
(c) It specifies the byte size of the element being written to disk
(d) none of these
Q:
Which statement is false?
a) Randomly accessed files are popular in transaction processing systems.
b) Data stored previously in a randomly accessed file can be updated or deleted without rewriting the entire file.
c) Records of a randomly accessed file are normally fixed in length (i.e., all the record in the file are the same length).
d) A record of a randomly accessed file is normally located by searching the portion of that file which precedes that record.
Q:
Which of the following is false?
(a) Data can be inserted in a randomly accessed file without destroying other data in the file.
(b) There is more than one way to implement randomly accessed files.
(c) Randomly accessed files cannot be accessed directly without searching through other records.
(d) Data stored previously can be updated or deleted without rewriting the entire file.
Q:
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
Q:
Which statement is true?
a) The file position pointer is a pointer to a FILE structure.
b) The file position pointer is a pointer to an FCB.
c) The file position pointer is not really a pointer.
d) The file position pointer specifies the file reset.
Q:
The rewind statement causes __________.
a) the disk to stop spinning, then spin in reverse until it repositions to the beginning of the file.
b) the contents of the file to be erased.
c) a program's file position pointer to be repositioned to the beginning of the file (i.e., byte 0).
d) a file to be closed and then re-opened.
Q:
Function fscanf is equivalent to function scanf, except that fscanf
a) can have only a single argument.
b) can read only from standard streams.
c) can read only from open streams.
d) receives as an argument a file pointer for the file from which the data is read.
Q:
Which of the following is a function that causes a program's file position pointer to be repositioned to the beginning of the file?
(a) rescan
(b) rewind
(c) return
(d) none of these
Q:
Function fscanf takes an argument of type ________.
(a) FILE pointer
(b) cfPtr
(c) char
(d) int
Q:
Which statement is true?
a) fopen returns a FILE structure.
b) fopen returns a pointer to a FILE structure.
c) fopen returns a file control block (FCB).
d) fopen returns a pointer to a file control block (FCB).
Q:
If an error occurs while opening a file in any mode, fopen __________.
a) causes program termination
b) returns NULL
c) issues the message "can"t open file"
d) diagnoses the error, waits five minutes and retries
Q:
Which statement is false?
a) Each file used in a program must have a unique name and will have a different file pointer returned by fopen.
b) All subsequent file processing functions after the file is opened must refer to the file with the appropriate file control block.
c) To create a file use file open mode "w".
d) To add records to an existing file, pen the file for appending ("a").
Q:
If a file is not closed explicitly by a program __________.
a) the operating system normally will close the file when program execution terminates
b) the file will be left open when the program terminates, creating a possible security breach
c) the operating system will query the user to determine if he or she wishes to close the file when the program terminates
d) the operating system will not allow the owner of that program to run any other programs
Q:
Which statement is true?
a) Function fprintf is equivalent to printf.
b) Function fprintf is equivalent to printf except that fprintf also receives as an argument a file pointer for the file to which the data will be written.
c) Function fprintf is equivalent to printf except that fprintf also receives as an argument a file control block for the file to which the data will be written.
d) Function fprintf is equivalent to printf except that fprintf also disables the file end-of-file indicator.
Q:
Function feof __________.
a) forces an end-of-file condition
b) determines whether the end-of-file indicator is set for a file
c) sets the end-of-file indicator for a file
d) flushes the contents of the file from the current position to the end
Q:
If an existing file is opened for writing __________.
a) the contents of the file are preserved
b) the contents of the file are discarded and an error code is returned
c) the contents of the file are discarded without warning
d) the newly written data is appended to the end of the file
Q:
Before a file can be accessed it must first be
a) copied
b) read
c) written
d) opened
Q:
Which of the following statements is false?
a) The programmer must know the specifics of the FILE structure to use files.
b) The FILE structure for a file leads indirectly to the operating system's file control block (FCB) for a file.
c) If a file does not exist and is opened for writing fopen creates the file.
d) A C program administers each file with a separate FILE structure.
Q:
Which statement is false?
a) The programmer must provide any file structure to meet the requirements of each particular application.
b) A programmer can impose a record structure on a file.
c) Records must be written to a C file in order by record key.
d) The notion of a record of a file does not exist in C.
Q:
Which statement is true?
a) C imposes no structure on a file.
b) C imposes record structure on a file.
c) C imposes sequential access on a file.
d) C imposes hierarchical access on a file.
Q:
If an error occurs while opening a file in any mode, function fopen returns ________.
(a) true
(b) NULL
(c) false
(d) -1
Q:
Which mode would you use if you wanted to open a file for both reading and writing?
(a) r+
(b) w+
(c) a+
(d) all of these
Q:
Function fputs writes a __________ to a file.
a) character
b) stream
c) line
d) standard output
Q:
Function __________ reads one character from a file.
a) fgetcharacter
b) fgetc
c) fgetchar
d) fgetbyte
Q:
The standard __________ stream enables a program to read data from the keyboard.
a) read
b) keyboard
c) dialog
d) input
Q:
__________ provide communication channels between files and programs.
a) Streams
b) Records
c) File descriptors
d) File control blocks (FCBs)
Q:
Which of the following is not automatically opened when a C program begins?
a) standard error
b) standard output
c) standard dialog
d) standard input
Q:
C views each file simply as a sequential stream of __________.
a) bits
b) bytes
c) fields
d) records
Q:
Which of the following is not part of the FILE structure specified in <stdio.h>?
(a) file descriptor
(b) open file table
(c) read/write methods
(d) file control block
Q:
Which of the following is not a stream associated with C files?
(a) stdin
(b) stdout
(c) stdchar
(d) stderr
Q:
Which of the following is false?
a) Storage of data in memory variables is temporary; all such data is lost when a program terminates.
b) Computers store files on primary storage devices, typically disk storage devices.
c) Files are used for permanent retention of data (typically large amounts of data).
d) Storage of data in memory arrays is temporary; all such data is lost when a program terminates.
Q:
________ are used for permanent retention of large amounts of data.
(a) Structures
(b) Arrays
(c) Records
(d) Files
Q:
Which of the following is true?
a) Any bit "ANDed" with 0 yields 0.
b) Any bit "ANDed" with 1 yields 1.
c) Any bit "ANDed" with 0 yields 1.
d) Any bit "ANDed" with 1 yields 0.
Q:
In bitwise manipulations, a mask is typically __________.
a) A floating point value with specific bits set to 1.
b) An integer value with specific bits set to 1.
c) An integer value with specific bits set to 0.
d) A floating point value with specific bits set to 0.
Q:
Which statement is true of the >> operator?
a) It is called the left shift operator.
b) It is called the bitwise left shift operator.
c) It shifts the bits of the first operand right by the number of bits specified by the second operand.
d) It fills from the left portably across platforms.
Q:
Which statement is true of the << operator?
a) It's called the right shift operator.
b) It's called the bitwise right shift operator.
c) It shifts the bits of the second operand left by the number of bits specified by the first operand.
d) It fills from the right with 0 bits.
Q:
Which operator sets the bits in the result to 1 if at exactly one of the corresponding bits in the two operands is 1?
a) bitwise AND
b) bitwise inclusive OR
c) bitwise exclusive OR
d) bitwise complement
Q:
Which operator sets the bits in the result to 1 if at least one of the corresponding bits in the two operands is 1?
a) bitwise AND
b) bitwise inclusive OR
c) bitwise exclusive OR
d) bitwise complement
Q:
Which operator sets the bits in the result to 1 only when the corresponding bits in the two operands are both 1?
a) bitwise AND
b) bitwise inclusive OR
c) bitwise exclusive OR
d) bitwise complement
Q:
The bitwise operators can be used to manipulate the bits of variables of type __________.
a) float
b) double
c) long
d) long double
Q:
For any eight-bit x, which of the following does not result in zero?
(a) x &= (~x)
(b) x ^= x
(c) x <<= 8
(d) x |= x
Q:
Let x be an int on a machine with four-byte ints. What effect does
x<<=1;
x>>=1;
have?
(a) There is no effect.
(b) The leftmost bit of x is set to zero.
(c) The rightmost bit of x is set to zero.
(d) Both (b) and (c).
Q:
Evaluate (00001000 & 11000101) ^ (11110000)
(a) 00111101
(b) 11000000
(c) 00111101
(d) 11110000
Q:
Let Bit1 = Bit2 = 1. Which of the following does not have the same result as the others?
(a) Bit1 & Bit2
(b) Bit1 | Bit2
(c) Bit1^Bit2
(d) ~(~Bit2)
Q:
Which of the following is not a bitwise operator?
(a) ^
(b) &
(c) ~
(d) *
Q:
The most basic unit of data on a computer is the
(a) bit.
(b) byte.
(c) file.
(d) int.