DOC PREVIEW
U of I CS 241 - Pop Quiz

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:

Pop QuizQuestion 1Question 2Question 3Question 4Question 5Copyright ©: Nahrstedt, Angrave, Abdelzaher1Pop Quiz5 multiple choice questions (75 seconds each)Please mark only ONE answer per questionIf more than one answer are partially correct, choose the single BEST answerAnswer in the bubble-sheet (get pen/pencil ready now)Slide show formatCopyright ©: Nahrstedt, Angrave, Abdelzaher2Question 1 Q1) Which of the following code snippets is/are wrong?Case 1 Case 2 Case 3int *p; char a[2]; int b[10];*p=10; strcpy (a, “Hi”); *b=11;a) Case 1.b) Case 2c) Case 3d) Both Case 1 and Case 2e) Both Case 1 and Case 3Wrong:Dereferencing uninitialized pointerWrong:No room for NULL characterHalf CreditCopyright ©: Nahrstedt, Angrave, Abdelzaher3Question 2Q2) Given what you know about memory caches, which of the following content is best to remove to make room for new content that arrives to a full cache? a) Remove randomly selected contentb) Remove the oldest content (i.e., content that resided in the cache for the longest amount of time)c) Remove the newest content (i.e., content that resided in the cache for the shortest amount of time) d) Remove the most recently requested contente) Remove least recently requested content Think what Blockbuster might dowhen it’s time to rotate the shelvesRandom?? Clearly a bad idea!Bad! Will remove the classics and other “oldies but goodies”That’s crazy! Will remove the new releases!Best thing to do! If it’s been ages since anyonerented the movie, it’s time to take it off the shelves.Copyright ©: Nahrstedt, Angrave, Abdelzaher4Question 3Q3) Which of the following lines is/are wrong, if any: Line 1: char s[10];Line 2: strcpy (s, “Hi”);Line 3: strcat (“John: ”, s);Line 4: strcat (s, “, there!!”);a) Line 2b) Line 3c) Line 4d) Lines 3 and 4e) All is correct. Wrong. Concatenating to a constant.Wrong.“Hi, there!!” exceeds array size.CorrectI will consider this correct if you did not realize that the four lines are the same program.Half creditCopyright ©: Nahrstedt, Angrave, Abdelzaher5Question 4Q3) Which of the following lines is/are wrong, if any: Line 1: int **p, *q;Line 2: p=&q;Line 3: q = (int*) malloc (10*sizeof(int));Line 4: **p = 10;a) Line 1b) Line 2c) Line 3d) Lines 4e) All is correct. Writes 10 in the location pointed to by thepointer pointed to by p. Since p points to qand q points to a location that has been properly allocated via malloc, all is well.Copyright ©: Nahrstedt, Angrave, Abdelzaher6Question 5Q1: What is wrong with the code snippet below:int* p, x, y=10;p= &y;while (y>0) {x=y--;printf (“x= %d”, x);y=x; }*p = x;a) Pointer treated as an integer b) Infinite loopc) Dereferencing an invalid pointerd) y is a constant but treated as a variablee) Both (a) and (d)Assigns y to x before decrementing y. Restores the old (undecremented) y. Hence the loop never changes


View Full Document

U of I CS 241 - Pop Quiz

Documents in this Course
Process

Process

28 pages

Files

Files

37 pages

File I/O

File I/O

52 pages

C Basics

C Basics

69 pages

Memory

Memory

23 pages

Threads

Threads

14 pages

Lecture

Lecture

55 pages

C Basics

C Basics

24 pages

Signals

Signals

27 pages

Memory

Memory

45 pages

Threads

Threads

47 pages

Threads

Threads

28 pages

LECTURE

LECTURE

45 pages

Threads

Threads

30 pages

Threads

Threads

55 pages

Files

Files

37 pages

SIGNALS

SIGNALS

22 pages

Files

Files

37 pages

Threads

Threads

14 pages

Threads

Threads

13 pages

Load more
Download Pop Quiz
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 Pop Quiz 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 Pop Quiz 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?