DOC PREVIEW
UVA CS 101 - PLEDGED

This preview shows page 1-2 out of 6 pages.

Save
View full document
View full document
Premium Document
Do you want full access? Go Premium and unlock all 6 pages.
Access to all documents
Download any document
Ad free experience
View full document
Premium Document
Do you want full access? Go Premium and unlock all 6 pages.
Access to all documents
Download any document
Ad free experience
Premium Document
Do you want full access? Go Premium and unlock all 6 pages.
Access to all documents
Download any document
Ad free experience

Unformatted text preview:

CS101 PLEDGED SPRING 2000CS 101 PLEDGED PAGE 1 OF 6The following exam is pledged. All answers are to be given on the provided answer sheet. The test isclosed book and closed note. For objective questions, if you believe more than one answer is acceptable,choose the most encompassing answer. YOU MUST HAND IN ALL COPIES OF THE TEST AND THEANSWER SHEET.PART I: True/False questions1. Computers use the binary number system. A single binary digit is called a byte.2. Object-oriented design and programming is a paradigm of programming in which a software systemis modeled as a set of objects that interact with each other.3. The manipulator endl inserts a '\n' in the output stream. In addition, it forces all the output thathas been sent to the stream to be written to the corresponding device.4. The expression "abc" is a legal value for a char object.5. C++ names are case sensitive. The names Temp and temp refer to two different objects.6. The assignment operator has higher precedence than the arithmetic operators.7. The following code fragment is legal.const float PayRate = 6.50;float OldSalary = PayRate * 40;PayRate = 7.25;float NewSalary = Payrate * 40;8. A logical expression is true if the value of the expression evaluates to either a nonzero integer valueor the value true.9. The operators == and != have different precedence than the operators <, <=, >,and>=.10. A logical expression that is being evaluated is subject to the short-circuit rule. This rule states thatonce the overall value of an expression is known, evaluation ceases. For example, if P is true, thenthe term Q is not evaluated in P||Qbecause the overall expression is true.11. According to the C++ standard, an object defined in the ForInit section of a for loop can be used onlyin that loop.12. Because a while test expression can be initially false, it is possible for the body of a while loop notto be executed.PART II: Fill in the blank13. We use a ________ directive to include the iostream library.14. The C++ stream operator << is called the ________ operator.15. Standard C++ programs begin executing in function ________ ().16. The input stream ________ normally corresponds to the keyboard.17. In a mixed-mode arithmetic expression, the ________ operand isconverted to the type of the floating-point operand.CS101 PLEDGED SPRING 2000CS 101 PLEDGED PAGE 2 OF 618. A return value of ________ indicates that function main() ran successfully.19. The length of the string "wahoo\n" is ________.20. The ________ class is designed for storing and manipulating sequences of characters.PART III: Multiple choice questions21. A CPU(a) Fetches, decodes and executes instructions(b) Performs Boolean and arithmetic operations(c) Issues input and output instructions(d) (a), (b), and (c)(e) (a) and (c)22. What is the output of the following code segment?int R = 10;int S = 20;int Z = 15;if(R<S){Z=R;}else {Z=S;}cout << Z;(a) 10(b) 20(c) 15(d) There is no about because the segment contains a syntax error(e) "S"23. Which is true about compilers and operating systems?(a) Compilers translate programs to executable form, operating systems link programs;(b) Compilers are the IDE, operating systems link programs.(c) Compilers translate programs to executable form, operating systems manage systemresources;(d) Compilers translate programs to executable form and link them for execution, operating sys-tems manage system resources;(e) Compilers link programs, operating systems are the IDECS101 PLEDGED SPRING 2000CS 101 PLEDGED PAGE 3 OF 624. Evaluate the following code segment to determine the initial value of Z.int R = 6;bool S = true;bool T = false;bool Z = !(S || !T) || (R <= 7);(a) 6(b) true(c) false(d) Cannot be determined without parentheses to establish evaluation order.(e) 725. Fill in the "not (P and Q)" column in the following truth table:Now count the number of trues and the number of falses in the last (not (P and Q)) column of thistable.(a) There are more true entries than false entries(b) There are more false entries than true entries(c) The number of true and false entries is equal(d) There are no true entries or false entries in the last column(e) Can't be determined because we don't know the value of P or the value of Q.26. What are the characteristics of an object in general?(a) It has a name and properties(b) It has a name, properties and behaviors(c) It can act on receiving a message(d) (a) and (c)(e) (b) and (c)27. Why is object-oriented programming useful?(a) It supports good software engineering practices(b) It promotes thinking about software in a way that models the way we think and interact nat-urally(c) It supports code reuse(d) (a) and (b)(e) (a), (b) and (c)P Q not (P and Q)false falsefalse truetrue falsetrue trueCS101 PLEDGED SPRING 2000CS 101 PLEDGED PAGE 4 OF 628. In C++, what are the contents in memory of a variable that has not been initialized?(a) Its value is undetermined(b) Zero(c) The last value assigned to it in a preceding program(d) False(e) '\0'29. What would happen if you tried to store a number in an integer variable, that was larger than the max-imum storable number in that integer?(a) If you tried to store a number larger than this number in an integer, the computer would notbe able to store it properly. The assignment would work, but when you try to access thevariable and evaluate its value, it would be incorrect.(b) When evaluated, the value of the variable would be negative(c) The variable stored in memory after the integer variable would be corrupted.(d) (a) and (b)(e) (a), (b) and (c)30. Would the expression ('ab' == "ab") be true in C++?(a) No, because the ASCII doesn't match(b) No because == should be =(c) No because an expression like this wouldn't compile(d) Yes(e) No, because 'ab' and "ab" need to be given initial values.31. Carefully consider the following code:int Count1 = 1;int Count2 = 2;if (Count1 == Count2)++Count2;else++Count1;++Count2;cout << Count1 << '\t' << Count2 << endl;What is the output of this code fragment?(a) 1 3(b) 1 4(c) 2 3(d) 2 2(e) No output; any program containing this code would have a compiler error.CS101 PLEDGED SPRING 2000CS 101 PLEDGED PAGE 5 OF 632. Consider:for(inti=1; i<=100; i++) {int count = 0;if((i%2)==0){count++;}}cout << count << endl;What is the output of this code fragment?(a) 0(b) 1(c) 50(d) 100(e) No output; any program containing this code would have a compiler error.Use the following definitions for Questions 33 - 37.char a;intq=7;intr=7;float s = 7.5;int t =


View Full Document

UVA CS 101 - PLEDGED

Documents in this Course
Classes

Classes

53 pages

Recursion

Recursion

15 pages

Iteration

Iteration

88 pages

Objects

Objects

33 pages

PLEDGED

PLEDGED

11 pages

CS 101

CS 101

42 pages

Classes

Classes

83 pages

Iteration

Iteration

92 pages

Classes

Classes

186 pages

Classes

Classes

208 pages

Hardware

Hardware

21 pages

Arrays

Arrays

70 pages

Load more
Download PLEDGED
Our administrator received your request to download this document. We will send you the file to your email shortly.
Loading Unlocking...
Login

Join to view PLEDGED and access 3M+ class-specific study document.

or
We will never post anything without your permission.
Don't have an account?
Sign Up

Join to view PLEDGED 2 2 and access 3M+ class-specific study document.

or

By creating an account you agree to our Privacy Policy and Terms Of Use

Already a member?