⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 ssd6-quiz.txt

📁 卡耐基梅陇大学的ssd6quiz答案
💻 TXT
📖 第 1 页 / 共 2 页
字号:
1. 
 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) III only
 (b) II and III only
 (c) I, II, and III.
 (d) I and III only  

 Correct answer is  (b)  

 Your score on this question is: 0.00  

 Feedback: 
   See section 1.1.3 of the course notes.
   (c)  
 



--------------------------------------------------------------------------------

 2. 
 The machine code generated from source code by a compiler  
 

  (a) does not preserve all the information given in the source code
 (b) associates variable values with their names
 (c) can be easily inspected to check the correctness of the compiler
 (d) executes more quickly than the source code  

 Correct answer is  (a)  

 Your score on this question is: 0.00  

 Feedback: 
   See section 1.1.3 of the course notes.
   (d) The source code never executes. It is compiled into machine code  
 

--------------------------------------------------------------------------------

 3. 
 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) I, II, and III.
 (b) II only
 (c) II and III only
 (d) III only  

 Correct answer is  (c)  

 Your score on this question is: 0.00  

 Feedback: 
   See section 1.2.3 of the course notes.
   (b)  
 

--------------------------------------------------------------------------------

 4. 
 Within Visual C++, which of the following will reveal the value of a variable when the program is stopped at a breakpoint? 
Placing the mouse pointer over the variable name in the source file window. 
Inserting a printf() in the program. 
Typing the variable name on the "Watch" window. 
 
 

  (a) I and III only
 (b) II and III only
 (c) III only
 (d) I, II, and III  

 Correct answer is  (a)  

 Your score on this question is: 7.14  

 Feedback: 
   See section 1.2.3 of the course notes.
   (a)  
 

--------------------------------------------------------------------------------

 5. 
 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) i, j and number only.
 (b) plusone only.
 (c) plusone and number only.
 (d) i only.  

 Correct answer is  (c)  

 Your score on this question is: 7.14  

 Feedback: 
   See section 1.4.2 of the course notes.
   (c)  
 

--------------------------------------------------------------------------------

 6. 
 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)?  
 

  (a) 0
 (b) 5
 (c) 1
 (d) 4  

 Correct answer is  (d)  

 Your score on this question is: 7.14  

 Feedback: 
   See section 1.4.2 of the course notes.
   (d)  
 

--------------------------------------------------------------------------------

 7. 
 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) 5
 (c) nothing: it will not compile successfully
 (d) 8  

 Correct answer is  (c)  

 Your score on this question is: 7.14  

 Feedback: 
   See section 1.4.1 of the course notes.
   (c)  
 

--------------------------------------------------------------------------------

 8. 
 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) Two different integers are printed, and the value of neither can be determined from the information given.
 (b) 5 and 4 are printed, in that order on the same line.
 (c) 5 is printed twice on the same line.
 (d) One integer is printed twice, and its value cannot be determined from the information given.  

 Correct answer is  (a)  

 Your score on this question is: 7.14  

 Feedback: 
   See section 1.4.1 of the course notes.
   (a)  
 

--------------------------------------------------------------------------------

 9. 
 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 value of *d is closer to the value of *c than to the value of *a.
 (c) The values of &a and &b are closer to each other than the values of &c and &d.
 (d) The values of *a and *b are closer to each other than the values of *c and *d.  

 Correct answer is  (a)  

 Your score on this question is: 7.14  

 Feedback: 
   See section 1.3.1 of the course notes.
   (a)  
 

--------------------------------------------------------------------------------

 10. 
 Consider the following segment of C source code. 
int a = 8;
int b = *&a;

What is the value of variable b at the end of execution of the segment?  
 

  (a) (int) &b
 (b) a
 (c) (int) &a
 (d) &a  

 Correct answer is  (b)  

 Your score on this question is: 7.14  

 Feedback: 
   See section 1.3.2 of the course notes.
   (b)  
 

--------------------------------------------------------------------------------

 11. 
 A CPU register is a word of CPU memory that  
 

  (a) houses a critical variable for the duration of the execution of a program
 (b) is automatically loaded when a CPU instruction refers to a word of normal memory
 (c) is explicitly loaded and unloaded from normal memory by compiler-generated instructions
 (d) records the results of periodic CPU diagnostics  

 Correct answer is  (c)  

 Your score on this question is: 7.14  

 Feedback: 
   See section 1.5.3 of the course notes.
   (c)  
 

--------------------------------------------------------------------------------

 12. 
 Consider the following pseudo-instructions. 
0x40B7D8 i = i - 1
0x40B7E0 branch-if-not-zero 0x40B7D8

Which of the following code fragments do the instructions encode? 
if (i != 0) i = i -1; 
while (--i); 
do { i = i - 1; } while (i); 
 
 

  (a) III only
 (b) II only
 (c) II and III only
 (d) I only  

 Correct answer is  (c)  

 Your score on this question is: 0.00  

 Feedback: 
   See section 1.5.2 of the course notes.
   (a)  
 

--------------------------------------------------------------------------------

 13. 
 How many return addresses does a C function have as a program executes?  
 

  (a) as many as the number of times it is invoked
 (b) one
 (c) two, one for each branch
 (d) as many as the number of return statements within the function  

 Correct answer is  (a)  

 Your score on this question is: 7.14  

 Feedback: 
   See section 1.5.2 of the course notes.
   (a)  
 

--------------------------------------------------------------------------------

 14. 
 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
 (c) the operation codes understood by the two processors are different
 (d) copyrights regarding code cannot be violated  

 Correct answer is  (c)  

 Your score on this question is: 0.00  

 Feedback: 
   See section 1.5.1 of the course notes.
   (b) The assembly mnemonics can be different and yet assemble into the same opcodes  
 


1. 
 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) I, II, and III.
 (c) II and III only
 (d) III only  

 Correct answer is  (c)  

 Your score on this question is: 7.14  

 Feedback: 
   See section 1.1.3 of the course notes.
   (c)  
 



--------------------------------------------------------------------------------

 2. 
 Which of the following is able to describe a computation at the highest level of abstraction?  
 

  (a) machine code
 (b) C++ code
 (c) logic Gates
 (d) C code  

 Correct answer is  (b)  

 Your score on this question is: 7.14  

 Feedback: 
   See section 1.1.2 of the course notes.
   (b)  
 

--------------------------------------------------------------------------------

 3. 
 Within Visual C++, which of the following will reveal the value of a variable when the program is stopped at a breakpoint? 
Placing the mouse pointer over the variable name in the source file window. 
Inserting a printf() in the program. 
Typing the variable name on the "Watch" window. 
 
 

  (a) I and III only
 (b) III only
 (c) II and III only
 (d) I, II, and III  

 Correct answer is  (a)  

 Your score on this question is: 7.14  

 Feedback: 
   See section 1.2.3 of the course notes.
   (a)  
 

--------------------------------------------------------------------------------

 4. 
 Which of the following must be true if a program is stopped at a specific line within the Visual C++ debugger? 
There is at least one breakpoint enabled. 
There is a breakpoint enabled on that line. 
There is a breakpoint enabled on the line preceding that line. 
 
 

  (a) none
 (b) I only
 (c) I and II only
 (d) I and III only  

 Correct answer is  (a)  

 Your score on this question is: 0.00  

 Feedback: 
   See section 1.2.2 of the course notes.
   (c)  
 

--------------------------------------------------------------------------------

 5. 
 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) cannot be determined from the information given.
 (b) 5
 (c) 8
 (d) 4  

 Correct answer is  (a)  

 Your score on this question is: 7.14  

 Feedback: 
   See section 1.4.1 of the course notes.
   (a)  
 

--------------------------------------------------------------------------------

 6. 
 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)?  
 

  (a) 1
 (b) 5
 (c) 4
 (d) 0  

 Correct answer is  (c)  

 Your score on this question is: 7.14  

 Feedback: 
   See section 1.4.2 of the course notes.
   (c)  
 

--------------------------------------------------------------------------------

 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) I and II only

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -