系统级编程选择题

更新时间:2023-05-16 02:17:01 阅读量: 实用文档 文档下载

说明:文章内容仅供预览,部分内容可能不全。下载后的文档,内容与下面显示的完全一致。下载之前请确认下面内容是否您想要的,是否完整无缺。

Multiple Choice Quiz 1 Question1

Compared to a sequence of machine code instructions, a fragment of C code 选择一个答案

a. does not engage any transistors during its execution

b. may describe the same algorithm c. describes the actions of the computer, not just of the CPU

d. is the native way to program most computers

Question2

Which of the following is able to describe a computation at the highest level of abstraction? 选择一个答案

Question3

Which of the following does a debugger do?

1. Analyze the source code to find programming errors. 2. Decode machine code generated by a compiler. 3. Stop execution of a program. 选择一个答案

Question4

Integrated programming environments make it difficult to mix and match tools from different sources. This is 选择一个答案

a. good, because it ensures compilation is not done incrementally by accident

b. bad, because all the tools will then have the same user interface

a. III only b. I and III only c. II and III only d. I, II, and III.

a. C++ code b. logic Gates c. C code d. machine code

may describe the same algorithm

c. good, because tools from different sources cannot be made to interact with each other

d. bad, because no single vendor is likely to be the source of all the best tools

Question5

Consider the following fragment of C++ source code. String msg; unsigned int x; int y; cin >> msg >> x >> y; cout << x + y;

Which of the following is (are) true regarding execution of the segment? 1. The input statement will always take the same amount of time to execute.

2. The output statement will always be executed immediately after the input statement. 3. If x and y are both positive, an integer greater than both will be printed. 选择一个答案

Question6

Which of t he following Visual C++ objects are contained within a "Project"? I.Files II.Visual C++ Solutions III.Flow charts 选择一个答案

Question7

When using a debugger to find the cause of a program's incorrect behavior, 选择一个答案

a. it is fastest to start by stopping the debugger long before the behavior appears

b. it is often necessary to start the program multiple times under the debugger

c. the faulty code fragment must first be

a. I, II and III b. I only c. II only d. II and III only

a. II and III only b. I and II only c. II only d. none

identified

d. the program is usually executed to the point at which the behavior occurs and then executed backwards to find the cause

Question8

In Visual C++, a Win32 Console Application is 选择一个答案

a. the simplest type of application Visual C++ can generate

b. the status window of the Visual C++ environment

c. a program that is able to control the operating system of a windows computer

d. built by using sophisticated "Application Wizards"

Multiple Choice Quiz 2 Question1

Which of the following could be represented by one bit of information? 选择一个答案

a. an ASCII character

b. the color of a single pixel on a true-color computer display

c. the position of a light switch d. the current channel of a television receiver

Question2

In C, what is the following binary number in hexadecimal? 11010101 选择一个答案

Question3

What is the value of the following C expression? 0x1234 ^ 0x5432 选择一个答案

Question4

What is the value of the following C expression? 0x1234 & 0x5432 选择一个答案

a. 0x1030 b. 0x1111 c. 0x5636 d. 0x6666

a. 0x1030 b. 0x5434 c. 0x4606 d. 0x5636

a. 0xAB b. 0x5D c. 0xB5 d. 0xD5

Question5

How is 46 (decimal) represented in an 8-bit 2's complement binary format? 选择一个答案

Question6

How is -10 (decimal) represented in an 8-bit 2's complement binary format? 选择一个答案

Question7

In a computer with 4-byte words, which of the following C expressions tests whether ptr contains the address of a word? I. (ptr & 3) == 0 II. (ptr | 3) == 0 III. (ptr % 4) == 0 选择一个答案

Question8

What happens in a C program when an addition would cause integer overflow? 选择一个答案

a. An incorrect result is produced and execution continues.

b. The correct value is coerced to a floating point number.

c. An exception-handler is called with the two operands as parameters.

d. Execution is terminated.

a. II only b. III only c. I only d. I and III only

a. 11111010 b. 10001010 c. 11110101 d. 11110110

a. 01000110 b. 00101100 c. 00011110 d. 00101110

Question9

What is the purpose of the exponent in floating point numbers? 选择一个答案

a. to indicate where the decimal or binary point should be

b. the mantissa is raised to the power of the exponent

c. to specify the superscript

d. to specify the base as binary, octal, or hexadecimal

Question10

Which of the following statements about floating-point numbers in C is true? I. Floating-point numbers are often only approximations of real numbers.

II. A 32-bit float only approximates decimal fractions, but a 64-bit double represents them exactly.

III. Floating-point numbers can represent any rational real number but not irrationals. 选择一个答案

Question11

Which of the following numerical operations is most likely to lead to loss of precision? 选择一个答案

Question12

In C, using default floating point settings, what happens when a floating-point computation results in an overflow? 选择一个答案

a. A special value "infinity" is computed, testable with _finite().

b. An exception is raised unless disabled by

a. Floating-point addition b. Integer multiplication c. Floating-point multiplication d. Integer addition

a. II only b. I and III only c. I only d. I and II only

calling _controlfp().

c. An erroneous value is computed and execution continues.

d. Program execution is halted.

Multiple Choice Quiz 3 Question1

The program counter contains 选择一个答案

a. the number of times a program has been executed

b. the number of CPU instructions a program has executed so far

c. the address of the CPU instruction that is about to be fetched

d. the amount of memory a program is currently using

Question2

Immediately after the CPU executes an instruction that is neither a branch nor a jump instruction, the program counter 选择一个答案

a. is incremented by one

b. is incremented to point to the following instruction

c. has a value that cannot be determined without further information

Question3

A CPU register is a word of CPU memory that 选择一个答案

a. is explicitly loaded and unloaded from normal memory by compiler-generated instructions

b. houses a critical variable for the duration of the execution of a program

c. is automatically loaded when a CPU instruction refers to a word of normal memory

d. records the results of periodic CPU diagnostics

Question4

Which of the following computations may be performed by exactly one CPU instruction?

d. remains unchanged

1. a = 5;

2. a = b + c * 5;

3. for (i = 0; i < 10; i += a[i++]); 选择一个答案

Question5

Suppose that, using a tool such as the memory window of Visual C++, we found that a certain set of contiguous memory locations contained the integer 0xC605CD623A8365000000. What could these memory locations hold?

1. the integer 0xC605CD623A8365000000 2. a string

3. a CPU instruction 选择一个答案

Question6

A branch instruction 选择一个答案

a. sets the program counter to one of two possible values

b. increases the program counter by a fixed amount

c. unconditionally sets the program counter to its operand

a. I and II only b. I only c. III only d. I, II, and III

a. II only b. I, II, and III c. I only d. I and II only

d. sets the program counter to one of many possible values

Question7

A jump instruction 选择一个答案

a. increases the program counter

b. changes a pointer to point to the next element of an array

c. changes the program counter only if its operand is equal to zero

d. unconditionally sets the program counter to its operand

Question8

The machine code generated from source code by a compiler 选择一个答案

a. does not preserve all the information given in the source code

b. can be easily inspected to check the correctness of the compiler

c. executes more quickly than the source code

d. associates variable values with their names

Question9

Which of the following are true of the effect that optimizations have on the machine code generated by compilers?

I.The resulting code will be faster and/or smaller. II.The resulting code will be clearer.

III.The resulting code will be harder to debug. 选择一个答案

Question10

Which of the following is a good reason (are good reasons) to equip the CPU with small amounts of fast memory?

I.To make the design of the compiler simpler II.To make some CPU instructions smaller III.To make some CPU instructions faster 选择一个答案

a. I and III only b. I and II only c. I, II, and III d. I only

a. II only b. I, II, and III c. II and III only d. III only

Question11

11.Which of the following must be true if a program is stopped at a specific line within the Visual C++ debugger?

I.There is at least one breakpoint enabled. II.There is a breakpoint enabled on that line.

III.There is a breakpoint enabled on the line preceding that line. 选择一个答案

Question12

Within Visual C++, which of the following will reveal the value of a variable when the program is stopped at a breakpoint?

I.Placing the mouse pointer over the variable name in the source file window. II.Inserting a printf() in the program.

III.Typing the variable name on the "Watch" window. 选择一个答案

Question13

Programs compiled for an Intel Pentium processor do not execute properly on a SPARC processor from Sun Microsystems because 选择一个答案

a. the memory of a SPARC CPU is numbered from top to bottom

b. the assembly mnemonics for the same "opcode" are different in the two processors

a. II and III only b. I, II, and III c. I and III only d. III only

a. none b. I only c. I and III only d. I and II only

c. copyrights regarding code cannot be violated

d. the operation codes understood by the two processors are different

Multiple Choice Quiz 4 Question1

The Visual C++ Memory window displays 选择一个答案

a. the contents of memory, interpreted as 32-bit integers, without the associated variable names

b. the names and values of variables in memory, interpreted in one of several ways

c. the names and values of variables in memory, interpreted as 32-bit integers no matter what the variables' types

d. the contents of memory, interpreted in one of several ways, without the associated variable names

Question2

Consider the following code fragment. int a; int b;

int main(int argc, char *argv[]) { int c; int d; ...

/* some code */ }

Which of the following must be true? 选择一个答案

a. The values of &a and &b are closer to each other than the values of &c and &d.

b. The values of *a and *b are closer to each other than the values of *c and *d.

c. The value of &d is closer to the value of &c than to the value of &a.

d. The value of *d is closer to the value of *c than to the value of *a.

Question3

Consider the following code.

char a[100];

a[99] = *((char *) (((int) &a[0]) + 4))

If integers are 32 bits wide, which of the following values is equal to a[99]? 选择一个答案

a. a[4] b. a[0] + 4

c. the integer stored in the bytes a[4], a[5], a[6] and a[7]

Question4

Which of the following statements about alignment within C struct's is true? 1. Alignment may cause the allocation of unused space. 2. Alignment is required by all modern processors.

3. Alignment can help processors access data more efficiently. 选择一个答案

a. I only

Question5 分数: 1/1

In C, assuming that an int takes 4 bytes, how many bytes are required to represent the following array? int a[12]; 选择一个答案

Question6 分数: 1/1

Given the following declaration and initialization of s, what is the value of the expression s[6]?

char s[] = "string"; 选择一个答案

a. 44 b. 12 c. 52 d. 48

d. a[3]

b. I and III only c. I, II, and III d. II and III only

a. an unpredictable value b. '\n' c. 'g' d. '\0'

Question7

In C, assuming that an int takes 4 bytes, if array a is declared as follows and a has the value 0x10000, what is the value of the expression a + 2? int a[12]; 选择一个答案

a. 0x10008

b. 8 plus the contents of location 0x10000

Question8

Given the address of a C struct at runtime, how is the address of a member element in the struct determined? 选择一个答案

a. The element name is looked up in a symbol table.

b. A constant offset associated with the member is added to the address.

c. A linear search is made from the base address of the struct.

d. The struct consists of an array of pointers to the elements of the struct.

Question9

In one computer, the bytes with addresses A, A+1, A+2 and A+3 contain the integer 256, and the variable declared with int * a; has the value A. In a different computer, the bytes with addresses B, B+1, B+2 and B+3 also contain the integer 256, and the variable declared with int * b has the valueB. Which of the following are necessarily true?The contents of A+1 are equal to the contents of B+1.

The contents of A+1 are equal to the contents of B+2. *a == *b 选择一个答案

c. 0x10004 d. 0x10002

a. III only b. I only

c. II and III only d. I and III only

Question10

We want the variable factorialfunc to hold the address of the first instruction of the following function:

int factorial(int n) { if (n == 1) return n; return n * factorial(n -1); }

How would we declare the variable? 选择一个答案

a. int (*factorialfunc)(int); b. int (int) * factorialfunc c. factorial() * factorialfunc;

d. we can't: C cannot extract the addresses of instructions.

Multiple Choice Quiz 5 Question1

Consider the program given below. #include

int callee(void) { int count = 5;

printf("%d ", (int) &count); return count; }

int main (int argc, char *argv[]) { int count = 4; count = callee();

printf("%d ", (int) &count); return 0; }

Which of the following describes the output of the program? 选择一个答案

a. 5 and 4 are printed, in that order on the same line.

b. One integer is printed twice, and its value cannot be determined from the information given.

c. Two different integers are printed, and the value of neither can be determined from the information given.

Question2

What does the following program print? int callee(int * count) { count++; return *count; }

int main (int argc, char *argv[]) { int count = 4; int retval;

retval = callee(&count); printf("%d", retval); return 0; } 选择一个答案

a. 4

d. 5 is printed twice on the same line.

b. 5 c. 8

d. cannot be determined from the information given.

Question3

What is printed as a result of execution of the following program? #include <stdio.h>

void callee(int * count) { (*count)++; }

int main (int argc, char *argv[]) { int count = 4; callee(&count); printf("%d", count); return 0; } 选择一个答案

a. 8 b. 5

c. It cannot be determined from the information given.

Question4

What does the following program print? void callee(int * count) { (*count)++; }

int main (int argc, char *argv[]) { int count = 4; callee(count); printf("%d", count); return 0; }

选择一个答案

a. 4 b. 8 c. 5

d. nothing: it will not compile successfully

d. 4

Question5

Consider the following function. int factorial(int n) { if (n == 1) return n; return n * factorial(n - 1); }

How many activation records are "popped" when it is invoked by the expression factorial(4)? 选择一个答案

Question6

Activation records are organized in stacks because 选择一个答案

a. they are seldom needed during program execution.

b. stacks allow activation records to be pushed and popped in any order.

c. functions need to access all the variables of the functions that call them.

d. stacks are simple enough for the hardware to manage.

Question7

When executing a function callee(), which of the following are true regarding the value of the frame pointer?

I.It marks the top of the stack frame of the function that invoked callee(). II.It marks the bottom of the stack frame of callee() III.It is the top of the stack. 选择一个答案

Question8

In one computer, the bytes with addresses A, A+1, A+2 and A+3 contain the integer 256, and

a. II only b. I and II only c. I only d. III only

a. 4 b. 5 c. 1 d. 0

the variable declared with int * a; has the value A. In a different computer, the bytes with addresses B, B+1, B+2 and B+3 also contain the integer 256, and the variable declared with int * b has the value B.

In a computer in which both addresses and integers are 32 bits wide, how many bytes of memory will the compiler allocate for following code fragment? int a;

int * b = &a; 选择一个答案

Question9

Consider the following program segment. int factorial(int * arg) { int n = *arg; if (n == 1) return n; return n * factorial(n - 1); }

When the segment is executed, the variable n is allocated to 选择一个答案

a. just one address, and it was chosen by the compiler

b. many addresses that were chosen by the compiler

c. just one address, and it is not known to the compiler

d. many addresses none of which is known to the compiler

Question10

At which of the following times is an activation record created? I.When a program starts executing. II.Every time a function is invoked. III.When a variable is declared. 选择一个答案

a. II only b. I and II only c. III only

a. 8 b. 4 c. 32 d. 0

d. II and III only

Question11

Consider the following program. int i; int j = 1;

int callee(int number) { int plusone;

plusone = number + 1; return plusone; }

int main (int argc, char *argv[]) { if (j == 1) return callee(i); return j; }

Which of the following are allocated in the activation record immediately after the function callee() is invoked? 选择一个答案

Question12

Consider the following program. int i;

int * jp = &i;

void main(int i, char * argv[]) { printf("%d %d\n", (int) &i, (int) jp); }

Which of the following describes what it prints? 选择一个答案

a. two very different integers

b. two values, one 4 greater than the other

c. nothing: it will not compile because it is ambiguous

Question13

Consider the following program.

d. two integers that are exactly the same

a. plusone only. b. i only.

c. i, j and number only. d. plusone and number only.

本文来源:https://www.bwwdw.com/article/s3y4.html

Top