COP3014 Final

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

Assuming that t is an array and tPtr is a pointer to that array, which expression refers to the address of element 3 of the array?

&t[ 3 ].

Three of the following expressions have the same value. Which of the following expressions has a value different from the others'?

*Ptr.

Which of the following can have a pointer as an operand?

++.

A double subscripted array element declared as a[ 3 ][ 5 ] has how many elements?

15.

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?

2012.

Given the following declaration, what is the value of b[ 1 ][ 0 ]? int b[ 2 ][ 2 ] = { { 1 }, { 3 , 4 } };

3.

In order to perform file processing in C++, which header files must be included?

<iostream> and <fstream>

Which of the following does not have a stream associated with it?

<iostream>.

Select the false statement.

A binary digit (bit) can store two values simultaneously.

What method should be used to pass an array to a function that does not modify the array and only looks at it using array subscript notation:

A constant pointer to constant data.

An array name is:

A constant pointer to nonconstant data.

To follow the principle of least privilege, the selectionSort function should receive the array to be sorted as:

A constant pointer to nonconstant data.

In general, which of the following contains the most amount of data?

A database.

A function that prints a string by using pointer arithmetic such as ++ptr to output each character should have a parameter that is:

A nonconstant pointer to constant data.

A function that modifies an array by using pointer arithmetic such as ++ptr to process every value should have a parameter that is:

A nonconstant pointer to nonconstant data.

A pointer cannot be assigned to:

A pointer of a type other than its own type and void without using the cast operator.

A message between two objects in a UML sequence diagram is represented by:

A solid line with a filled arrowhead.

Which of the following is not true?

A subscript cannot be an expression.

Which of the following is not true of class template vector?

A vector can only store data type int.

For an ifstream object A, a class type B and a local variable of type B called C, the proper way to read in one B object from A into C is:

A.read( reinterpret_cast< char * >( &C ), sizeof( B ) );.

Pascal lacks which feature found in both Ada and Java?

Ability to specify simultaneous activities.

Which of the following does not declare a 2-by-2 array and set all four of its elements to 0?

All of the above initialize all of their elements to 0.

Random access files are more effective than sequantial files for:

All of the above.

Linear search can be used on:

Any of the above.

A random access file is organized most like a(n):

Array.

In order to calculate the _______ of an array of values, the array of values must be summed.

Average.

The data hierarchy, arranged from smallest to largest, is:

Bit, byte, field, record, file.

Pointers may be assigned to which of the following?

Both (b) and (c).

Pointers may be assigned which of the following values?

Both (b) and (c).

Unless otherwise specified, entire arrays are passed ________ and individual array elements are passed

By reference, by value.

Which of the following is not a valid way to pass arguments to a function in C++?

By value with pointer arguments.

Today, virtually all new major operating systems are written in:

C or C++.

Which language was developed expressly for the .NET platforM?

C#.

Select the false statement.

C++ files include information about their structure.

Constant variables:

Can be used to specify array sizes, thereby making programs more scalable.

Referencing elements outside the array bounds:

Can result in changes to the value of an unrelated variable.

Select the false statement. The reinterpret_cast operator:

Changes the value of the object to which its operand points.

A string array is commonly used for:

Command-line arguments.

Preprocessor directives are processed before the C++ program is:

Compiled.

Which of the following statements is true?

Compilers translate high-level language into machine language.

strtok does not:

Completely tokenize the string the first time it is called.

All of the following could cause a fatal execution-time error except:

Dereferencing a variable that is not a pointer.

Select the false statement. When objects are saved to a file:

Different types of objects cannot be written to the same file.

Using square brackets ([]) to retrieve vector elements __________ perform bounds checking; using member function at to retrieve vector elements __________ perform bounds checking.

Does not, does.

Which of the following languages is used primarily for scientific and engineering applications?

FORTRAN.

Which of the following is not one of the benefits of object-oriented programming?

Fewer source code files.

Strings represented as character arrays cannot:

Grow or shrink dynamically.

C++ is a:

Hybrid object-oriented language.

Java was originally developed for:

Intelligent consumer devices.

( *max )( num1, num2, num3 );:

Is a call to the function pointed to by max.

A string array:

Is actually an array of pointers.

Which of the following statements is false about a function to which an array is being passed?

It always knows the size of the array that is being passed.

Which of the following is false about a function to which an array is being passed?

It knows the size of the array that is being passed.

Which of the following is not a computer?

LAN.

Linear search is highly inefficient compared to binary search when dealing with:

Large, sorted arrays.

What is not true about this code segment? location = fileObject.tellg();

Location is a pointer.

An array is not:

Made up of different data types.

In a UML communication diagram, the first message passed during the processing of message 1 is called:

Message 1.1.

The scheduling procedure that increases throughput by minimizing idle time is:

Multiprogramming.

What does the following declaration declare? int*countPtr, count;

One pointer to an int and one int variable.

Which statement is not true about 0, z, %, * and Q?

Only two of the elements listed are in typical character sets.

Which of the following is not a disadvantage of trying to modify a sequential access file?

Overwriting a record with another record of the same size is very difficult.

Consider the following function: void reverse( char * string1, const char * string2 ) { int stringsize = sizeof( string1 )/sizeof( char ); *( string1 + stringsize -1 ) = '\0'; string1 = string1 + stringsize - 2; for ( ; *string2 != '\0'; string1--, string2++ ) *string1 = *string2; } What method does the function use to refer to array elements?

Pointer/offset notation.

Which of the following is not one of the six logical units of a computer?

Printer.

Pointers cannot be used to:

Reference values directly.

sizeof:

Returns the total number of bytes in a variable.

Which of the following is not one of the three general types of computer languages?

Spoken languages.

Which of the following is false for pointer-based strings?

String literals are written inside of single quotes.

Which of the following is not true?

String literals are written inside of single quotes.

Assuming that string1 = "hello" and string2 = "hello world", which of the following returns 0?

Strncmp( string1,string2,5 );.

An algorithm that could execute for an unknown amount of time because it depends on random numbers may:

Suffer from indefinite postponement.

Which of the following statements about the C++ Standard Library is false:

The C++ Standard Library functions and classes are not included in every C++ implementation.

Which statement about insertion sort is true?

The algorithm is very simple compared to other sorting procedures.

To prevent modification of array values passed to a function:

The array parameter can be preceded by the const qualifier.

At the ith iteration of the insertion sort:

The first i elements of the array are sorted.

An activation, represented by a thin vertical rectangle, on an object's lifeline indicates that:

The object is executing.

Which of the following is not part of a computer's hardware?

The operating system.

In a typical nested for loop structure used to process a two-dimensional array, following the end of the each execution of the inner for loop:

The outer for loop increments its counter variable.

After the ith iteration of the selection sort:

The smallest i items of the array will be sorted into increasing order in the first i elements of the array.

Which of the following is not true of pointers to functions?

They cannot be assigned to other function pointers.

Comparing pointers and performing pointer arithmetic on them is meaningless unless:

They point to elements of the same array.

When used with ofstream objects, operator! is not:

Used to close a file explicitly.

Select the false statement. The write function:

Writes to files in hexadecimal format.

Assuming that int a has a value of 3 and that integer array b has 7 elements, what is the correct way to assign the value of the third element plus 3, to the fifth element of the array:

b[ a + 1 ] = b[ a - 1 ] + 3;.

Which of the following character array declarations does not produce a string?

char string1[] = { 't', 'e', 's', 't' };.

cin.getline ( superstring, 30); is equivalent to which of the following?

cin.getline( superstring, 30,'\n' );.

Which of the following will not change the file-position pointer to the same position as the others? Assume a 10-byte file size and a current position at byte # 1.

fileObject.seekg( 8, ios::end );.

Select the proper object type. __________ file( "file.dat", ios::in | ios::out);

fstream.

When a compiler encounters a function parameter for a single-subscripted array of the form int a[], it converts the parameter to:

int * a.

Which statement would be used to declare a 10-element integer array c?

int c [ 10 ];.

Which of the following is not a correct way to initialize an array?

int n [ 5 ] = { 0, 7, 0, 3, 8, 2 };

Which file open mode would be used to write data only to the end of an existing file?

ios::app.

To write fixed-length records, use file open mode:

ios::binary.

Which of the following is not true about files?

istream, ostream and iostream are derived from ifstream, ofstream and fstream, respectively.

The & operator can be applied to:

lvalues.

Which of the following best describes the array name n in the declaration int n[10];?

n is a constant pointer to nonconstant data

Which of the following gives the number of elements in the array int r[ 10 ]?

sizeof r / sizeof ( int )

Which of the following gives the number of elements in the int array r[ ]?

sizeof r / sizeof ( int ).

Which of the following correctly copies the contents of string2 into string1? Assume that string2 is equal to "goodbye" and string1 is equal to "goodmorning"?

strcpy( string1,string2 );.

Which of the following functions would not be used to write data randomly to a random access file?

tellg.


Set pelajaran terkait

Google Analytics & Principles of Marketing

View Set

(Unit 2B) Quiz 2B7- What You Need to Know About Completing a Job Application

View Set

CH 15 Lab Textbook Reading and Reading Questions

View Set

翰林-BOOK 4-第三次月考-文法選擇

View Set

An Invitation to Social Psychology Quiz Chapter 1

View Set

10 - Project Communications Management

View Set

Regulations: Securities Act of '33 Review Questions

View Set

Ch. 7 Computer Systems Management

View Set

english 9A - unit 1; lesson 4: parts of speech & patterns of word change

View Set