?? ssd6-choice.txt
字號:
Analyze the source code to find programming errors.
Decode machine code generated by a compiler.
Stop execution of a program.
(a) I and III only
(b) II and III only
(c) III only
(d) I, II, and III.
Correct answer is (b)
Your score on this question is: 0.00
Feedback:
See section 1.1.3 of the course notes.
--------------------------------------------------------------------------------
2.
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?
The input statement will always take the same amount of time to execute.
The output statement will always be executed immediately after the input statement.
If x and y are both positive, an integer greater than both will be printed.
(a) I and II only
(b) none
(c) II and III only
(d) II only
Correct answer is (b)
Your score on this question is: 7.14
Feedback:
See section 1.1.1 of the course notes.
--------------------------------------------------------------------------------
3.
When using a debugger to find the cause of a program's incorrect behavior,
(a) the program is usually executed to the point at which the behavior occurs and then executed backwards to find the cause
(b) the faulty code fragment must first be identified
(c) it is fastest to start by stopping the debugger long before the behavior appears
(d) it is often necessary to start the program multiple times under the debugger
Correct answer is (d)
Your score on this question is: 0.00
Feedback:
See section 1.2.4 of the course notes.
--------------------------------------------------------------------------------
4.
When debugging using Visual C++, which of the following are possible through the Watch window?
The program's execution can be stopped.
The value of an arbitrary C expression can be calculated.
The value of a program variable can be set.
(a) II only
(b) III only
(c) I, II, and III.
(d) II and III only
Correct answer is (d)
Your score on this question is: 0.00
Feedback:
See section 1.2.3 of the course notes.
--------------------------------------------------------------------------------
5.
Activation records are organized in stacks because
(a) they are seldom needed during program execution.
(b) stacks are simple enough for the hardware to manage.
(c) stacks allow activation records to be pushed and popped in any order.
(d) functions need to access all the variables of the functions that call them.
Correct answer is (b)
Your score on this question is: 0.00
Feedback:
See section 1.4.2 of the course notes.
--------------------------------------------------------------------------------
6.
Consider the following program.
int square(int * arg) {
int n = * arg;
return n * n;
}
int main (int argc, char * argv[]) {
int arg = strtol(argv[1], NULL, 0);
return square(arg);
}
When it is executed with the argument 5, the variable n is allocated to
(a) many addresses chosen by the compiler.
(b) exactly one address chosen by the compiler.
(c) exactly one address not known to the compiler.
(d) many addresses neither of which are known to the compiler.
Correct answer is (c)
Your score on this question is: 0.00
Feedback:
See section 1.4.1 of the course notes.
--------------------------------------------------------------------------------
7.
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?
(a) plusone only.
(b) i, j and number only.
(c) i only.
(d) plusone and number only.
Correct answer is (d)
Your score on this question is: 0.00
Feedback:
See section 1.4.2 of the course notes.
--------------------------------------------------------------------------------
8.
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) 8
(b) 5
(c) cannot be determined from the information given.
(d) 4
Correct answer is (c)
Your score on this question is: 7.14
Feedback:
See section 1.4.1 of the course notes.
--------------------------------------------------------------------------------
9.
In a computer in which both addresses and integers are 32 bits wide, how many bytes of memory will the compiler allocate as a result of the following pointer declaration?
int * pointer;
(a) 4
(b) 8
(c) 0
(d) 64
Correct answer is (a)
Your score on this question is: 7.14
Feedback:
See section 1.3.2 of the course notes.
--------------------------------------------------------------------------------
10.
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 value of *d is closer to the value of *c than to the value of *a.
(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 values of &a and &b are closer to each other than the values of &c and &d.
Correct answer is (c)
Your score on this question is: 7.14
Feedback:
See section 1.3.1 of the course notes.
--------------------------------------------------------------------------------
11.
Which of the following is a good reason (are good reasons) to equip the CPU with small amounts of fast memory?
To make the design of the compiler simpler
To make some CPU instructions smaller
To make some CPU instructions faster
(a) III only
(b) I, II, and III
(c) II only
(d) II and III only
Correct answer is (d)
Your score on this question is: 0.00
Feedback:
See section 1.5.3 of the course notes.
--------------------------------------------------------------------------------
12.
Programs compiled for an Intel Pentium processor do not execute properly on a SPARC processor from Sun Microsystems because
(a) the assembly mnemonics for the same "opcode" are different in the two processors
(b) copyrights regarding code cannot be violated
(c) the operation codes understood by the two processors are different
(d) the memory of a SPARC CPU is numbered from top to bottom
Correct answer is (c)
Your score on this question is: 0.00
Feedback:
See section 1.5.1 of the course notes.
(a) The assembly mnemonics can be different and yet assemble into the same opcodes
--------------------------------------------------------------------------------
13.
Immediately after the CPU executes an instruction that is neither a branch nor a jump instruction, the program counter
(a) has a value that cannot be determined without further information
(b) is incremented to point to the following instruction
(c) remains unchanged
(d) is incremented by one
Correct answer is (b)
Your score on this question is: 0.00
Feedback:
See section 1.5.2 of the course notes.
--------------------------------------------------------------------------------
14.
A branch instruction
(a) sets the program counter to one of two possible values
(b) sets the program counter to one of many possible values
(c) increases the program counter by a fixed amount
(d) unconditionally sets the program counter to its operand
Correct answer is (a)
Your score on this question is: 0.00
Feedback:
See section 1.5.2 of the course notes.
--------------------------------------------------------------------------------
Go to top of assessment.
Total score: 28.57
? Copyright 2005 iCarnegie, Inc. All rights reserved.
View Assessment Result: Multiple-Choice Quiz 1
Your performance was as follows:
1.
Compared to a sequence of machine code instructions, a fragment of C code
(a) may describe the same algorithm
(b) describes the actions of the computer, not just of the CPU
(c) is the native way to program most computers
(d) does not engage any transistors during its execution
Correct answer is (a)
Your score on this question is: 7.14
Feedback:
See section 1.1.2 of the course notes.
--------------------------------------------------------------------------------
2.
Which of the following does a debugger do?
Analyze the source code to find programming errors.
Decode machine code generated by a compiler.
Stop execution of a program.
(a) I and III only
(b) III only
(c) I, II, and III.
(d) II and III only
Correct answer is (d)
Your score on this question is: 7.14
Feedback:
See section 1.1.3 of the course notes.
--------------------------------------------------------------------------------
3.
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) built by using sophisticated "Application Wizards"
(d) a program that is able to control the operating system of a windows computer
Correct answer is (a)
Your score on this question is: 0.00
Feedback:
See section 1.2.1 of the course notes.
--------------------------------------------------------------------------------
4.
When debugging using Visual C++, which of the following are possible through the Watch window?
The program's execution can be stopped.
The value of an arbitrary C expression can be calculated.
The value of a program variable can be set.
(a) II only
(b) III only
(c) I, II, and III.
(d) II and III only
Correct answer is (d)
Your score on this question is: 7.14
Feedback:
See section 1.2.3 of the course notes.
--------------------------------------------------------------------------------
5.
Consider the function factorial() defined as follows.
int factorial(int n) {
if (n == 1) return n;
return n * factorial(n - 1);
}
How many activation records of factorial are allocated by invocation of the expression factorial(4)?
(a) 5
(b) 4
(c) 0
(d) 1
Correct answer is (b)
Your score on this question is: 7.14
Feedback:
See section 1.4.2 of the course notes.
--------------------------------------------------------------------------------
6.
When executing a function callee(), which of the following are true regarding the value of the frame pointer?
It marks the top of the stack frame of the function that invoked callee().
It marks the bottom of the stack frame of callee()
It is the top of the stack.
(a) I and II only
(b) III only
(c) II only
(d) I only
Correct answer is (a)
Your score on this question is: 7.14
Feedback:
See section 1.4.2 of the course notes.
--------------------------------------------------------------------------------
7.
At which of the following times is an activation record created?
When a program starts executing.
Every time a function is invoked.
When a variable is declared.
(a) III only
(b) I and II only
(c) II and III only
(d) II only
Correct answer is (b)
Your score on this question is: 7.14
Feedback:
See section 1.4.2 of the course notes.
(b) The program starts executing by calling the function main().
--------------------------------------------------------------------------------
8.
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) 5
(b) 8
(c) cannot be determined from the information given.
(d) 4
Correct answer is (d)
Your score on this question is: 0.00
Feedback:
See section 1.4.1 of the course notes.
--------------------------------------------------------------------------------
9.
Consider the following segment of a C program.
int i = 99;
int a[100];
i = a[i + 1];
Which of the following is true of the segment?
(a) When executed, the program will be prematurely terminated by the operating system because of an illegal memory access.
(b) i will have the value of the last element of the array a at the end of any execution of the segment.
(c) i will have the value 99 at the end of any execution of the segment.
(d) Execution will fail because a has the wrong size.
Correct answer is (c)
Your score on this question is: 7.14
Feedback:
See section 1.3.5 of the course notes.
--------------------------------------------------------------------------------
10.
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 value B. 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
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -