Computer Science 215 Quiz 1 Name ______________________ ----- PLEASE ALSO WRITE YOUR NAME OF THE BACK OF THE PAPER ------ ----- PLEASE DO NOT FOLD THE PAPER ------ ----- You may leave when you finish ------ 1. In the C language a variable of type "char" a. is used to hold character data b. holds 8 bit integers but not numeric data c. holds 16 bit integers d. holds 32 bit integers 2. A statement such as: (x + y) = y + 5; appearing in a C program will d. Cause a compile time error b. Cause a segmentation fault because (x + y) is not a legal at run time because no place "lvalue". to store the value has been provided c. Compile fine and do nothing to alter the state of the program at run time. 3. Which best characterizes the behavior of the following statements x = y; if (x = 0) printf("%d\n", x); a. the "if" statement will b. The print statement will cause a syntax error. never be executed c. the print statement will d. the print statement will be always be executed executed if the value of "y" is zero. 4. The C expression 'A' + 0x0a + 80 a. is illegal because of the b. has the decimal value 80 mixed modes in which the constants appear c. has the decimal value 75 d. has the decimal value 77 5. Add parentheses to the following expression that will ensure that the & operation is done LAST regardless of normal precedence x + y & z * 4 Computer Science 215 Quiz 2 Name ______________________ 1. Suppose the following is executed: int i, j; scanf("%3d %2d", &i, &j); and the input that is typed in is: 1234567 89 0 What values will be assiged to i and j i = j = 2. Suppose the following code is executed: int i, j; scanf("%d %d", &i, &j); and the following input is provided: A 2 4 a. i will be set to 65 b. i will be set to 2 j will be set to 2 j will be set to 4 c. i will be set to 65 d. neither i nor j will j will not be set at all be set 3. Which is the correct way to test for end of file when reading in exactly two integers at a time using scanf() a. while (scanf("%d %d", &i, &j) >= 0) b. while (scanf("%d %d", &i, &j)==2) c. while (scanf("%d %d", &i, &j) != EOF) 4. Which pair of statements is the proper way to read a numeric value into an integer variable declared as "int n;" and then print it out: a. scanf("%d", n); b. scanf("%d", n); printf("%d\n", n); printf("%d\n", &n); c. scanf("%d", &n); d. scanf("%d", &n); printf("%d\n", n); printf("%d\n", &n); 5. Suppose the following code is executed: char c; scanf("%c", &c); printf("%d", c); If the letter character 3 is entered from the keyboard as input the output will be: a. 3 b. c c. 51 d. no output -- this will cause a segfault. Computer Science 215 Quiz 3 Name ______________________ 1. If a C program is to read from the standard input using fscan(stdin, "%d", &c); a. The program must contain a b. The program must contain a FILE *stdin; FILE stdin; declaration. declaration. c. The program must NOT declare stdin because it must be predeclared in stdio.h 2. Which best characterizes the action taken when reading a file with fscanf() and with fgetc() a. fscanf() may consume multiple b. both fscanf() and fgetc() bytes from the file in a single consume exactly one byte call, but a call to fgetc() will per call. consume at most 1 byte. c. both fscanf() and fgetc() consume multiple bytes per call. 3. The fgets() function a. reads a single byte from b. always reads a specified number a file of bytes from a file c. stops reading when it finds d. stops reading when it finds a a '\n' newline character or null character or fills the fills the specified buffer specified buffer space. space. 4. Suppose the fputs() function is called as follows: fputs(buf, stdout); Which best describes how the function will operate. a. A single byte stored at location b. The value "buf" will be interpreted buf will be sent to stdout as a pointer and whatever byte it points to will be sent to stdout. c. "buf" will be viewed as a pointer d. "buf" will be viewed as a pointer and bytes starting at the location and bytes starting at the location to which it points will be sent to which it points will be sent to stdout until a \n (newline is to stdout until a NULL (byte having found) the value 0 is found) 5. If the set of marked parentheses is removed from the following: | | V V while ((len = fread(buff, 1, 1024, stdin)) != 0) { fwrite(buff, 1, len, stdout); the problem that will occur is: a. a segfault on the first call b. each call to fwrite will write to fread 1024 bytes instead of the number of bytes read c. each call to fwrite will cause d. each call to fwrite will cause 0 only 1 byte to be written bytes to be written. Computer Science 215 Quiz 4 Name ______________________ 1. Which best characterizes the behavior of the following program: main() { int *p; *p = 99; printf("The value is %d \n", *p); } a. The program is correct and b. The program is incorrect should be expected to work and will fail in all environments fine in all environments before the printf() is executed c. The program is incorrect, but it may appear to work correctly. 2. The main advantage to changing the program as follows is: main() { int *p = NULL; *p = 99; printf("The value is %d \n", *p); } a. It makes the program work b. It ensures that the program will correctly in all cases NEVER appear to work correctly c. There is no difference.. The two versions will work the same all of the time. 3. What the output of the following program will be: main() { a. 5 11 b. 11 12 int y = 5; int *p; c. 11 11 d. 5 12 p = &y; *p = 11; printf("%d ", y); y = 12; printf("%d", *p); } 4. Suppose the following declarations are made in a program to be run on an Intel x86 computer. char *x; short *y long *z; a. Each of the three pointer b. The three pointer variables consume variables consumes 4 bytes 1, 2, and 4 bytes respectively of space. 5. Which of the following variables will reside on the runtime stack: main() a. all of them b. y, a { int y; c. p, a d. y, p int *p; static int a; Computer Science 215 Quiz 5 Name ______________________ 1. Which is a correct way to dynamically allocate storage for an array of 100 integers. (For questions 1, 2, 3 assume that the pointer variable pi is declared as: int *pi; a. pi = (int *)malloc(4 * 100); b. pi = (int *)malloc(100); c. pi = (int *)malloc(4 * sizeof(int)); 2. The proper way to read a value from the standard input into the dynamically allocated storage is: a. scanf("%d", &pi); b. scanf("%d", pi); c. scanf("%d", *pi); 3. Suppose the values of the 100 integers are to be printed in a for () loop. In each interation through the loop, the proper way to update the pointer used to point to the next value to be printed is: a. pi = pi + 4; b. pi = pi + 1; c. pi = pi + sizeof(int); d. pi = pi + 100; 4. The proper way to access a pixel at position (row, col) in a binary encoded grayscale image pointed to by unsigned char *imageloc is: a. *(imageloc + row * numrows + col) b. *(imageloc + col * numrows + col) c. *(imageloc + col * numrows + row) d. *(imageloc + row * numcols + col) 5. Suppose a program is to be run as follows: a.out 1024 768 where the 1024 represents the number of columns and 768 the number of rows in an image to be created. The correct way to store the 768 value in a variable named numrows having type int is: a. numrows = argv[2]; b. numrows = atoi(argv[3]); c. numrows = scanf("%d", argv[2]); d. none of these will work. Computer Science 215 Quiz 6 Name ______________________ 1. Compute the dot product (1, 2, 1) dot (2, -1, 4) = 2. Compute the length of the vector (-1, 2, 3) (No calculators are needed -- you may leave the square root symbol in your answer). || (-1, 2, 3) || = 3. Compute the vector difference of: (1,-2, 4) - (2, -1, -3) = 4. In class last time we described how this function void vl_unitvec3( double *vin, double *vout) { *(vout + 0) = *(vin + 0) / vl_length3(vin); *(vout + 1) = *(vin + 1) / vl_length3(vin); *(vout + 2) = *(vin + 2) / vl_length3(vin); } could return the wrong answer when invoked as vl_unitvec3(v, v); Identify ALL of the following v's for which the answer returned will be INCORRECT: a. v = (3, 4, 5) b. v = (4, 0, 0) c. v = (0, 5, 0) d. v = (1/sqrt(2), 0, 1/sqrt(2)) 5. Which of the following should DETER you from choosing a particular occupation as your career: a. you really like it b. you are really good at it c. you find it incredibly difficult and frustrating and consequently you don't really like anything about it. Computer Science 215 Quiz 7 Name ______________________ 1. Suppose the following have been defined: struct pixtype struct pixtype *pixp; { unsigned char r; unsigned char g; unsigned char b; }; The correct way to access the "green" component of the pixel stored at (row, col) in an image buffer pointed to by struct pixtype *pixp is: a. *(pixp + 3 * row * numcols + 3 * col + 1); b. (pixp + 3 * row * numcols + 3 * col)->g c. (pixp + row * numcols + col).g d. (pixp + row * numcols + col)->g 2. In the definition: struct pix pixel; a. both pix and pixel are types and b. pix is a type but pixel is not instances of variables an instance c. pixel is a type and pix is an d. both pixel and pix are instances instance of variables. 3. Given the following structure definition, which of the following is syntactically correct. struct new a. v[1].a = 1; b. v.a[1] = 1; { int a; c. v.b[1] = 1.5; d. v[1].b = 1.5; float b[2]; }; struct new v; 4. Given the following structure definition, which of the following is syntactically correct. struct new a. v[1].a[1] = 1; b. v[0].b[1] = 1.0; { int a; c. v.b[1] = 1.5; d. v.a[1] = 1.5; float b[2]; }; struct new v[3]; 5. Consider the following definitions: struct pix struct pix p1; { struct pix *p2; unsigned char r; unsigned char g; unsigned char b; }; circle ALL of the following assignments that are syntactically correct: a. p1->r = 250; b. p2.r = 250; c. *(p2).r = 250; d. p1.r = 250; Computer Science 215 Quiz 8 Name ______________________ 1. In the raytracing algorithm which of the following steps requires the most code. a. compute the world coordinates of the pixel b. compute the direction in 3-d space of a ray from the viewpt through the pixel c. compute the color of the pixel based upon the illumination of the object(s) hit by the ray 2. Which best characterizes the "roll your own" inheritence mechanism we described last time: a. the obj_t is a base class and b. the sphere_t is a base class and the sphere_t a derived class the obj_t a derived class c. both are derived classes d. both are base classes. 3. The primary purpose of the model_t structure was to a. unnecessarily complicate the b. increase the number of parameters design of the ray tracer that must be passed from function to function. c. reduce the number of parameters that must be passed between functions 4. In the design discussed in class last time there is a single instance of the list_t structure a. for the entire raytracing b. for each list of obj_t's system c. for each instance of an obj_t 5. The "priv" pointer a. resides in an obj_t and points b. resides in a sphere_t or to a sphere_t or plane_t plane_t and points to an obj_t c. resides in an obj_t and points d. resides in a list_t and points to a list_t to an obj_t Computer Science 215 Quiz 9 Name ______________________ 1. Suppose V is the view point and W is the world coordinates of the point on the screen through which the ray passes. A unit vector in the direction of the ray is given by: a. V / || V || b. W / || W || c. (V - W) / || (V - W)|| d. (W - V) / || (V - W) || 2. Suppose V is the viewpoint D is a unit vector in the direction of the ray and "t" is the distance from V to the hitpoint H. The location of H is: a. H = V dot D / t b. H = t V + D c. H = tD + V d. H = t ( V dot D) 3. Suppose a ray is fired from viewpoint V with unit direction vector D. The ray is parallel to the plane if: a. V dot D = 0 b. V dot N = 0 c. D dot N = 0 d. (N - D) dot V = 0 4. Suppose a plane is defined by N = (0, 0, 1) and Q = (0, 0, -6) where N is the normal and Q is a point on the plane. Suppose V = (4, 2, 2) and D = (0, 0, -1) a. The distance from V to the Hitpoint? b. Give the coordinates of the Hitpoint Hint: Although it is possible to solve this using the plug and pray method with formulas presented in class, this approach will take excessive time and is likely produce arithmetic errors. The correct approach is to visualize the geometry of the problem in your head (or on paper). If you do that correctly, the solution can be readily computed in your head with resorting to any dot products. Computer Science 215 Quiz A Name ______________________ Suppose that the viewpoint is on one side of the screen and a sphere is on the other. The distance from the viewpoint to the hitpoint is given by t = (-b +/- sqrt(b^2 - 4ac))/2a 1. The correct root of the equation to use in determining the hitpoint is a. t = (-b - sqrt(b^2 - 4ac))/2a b. t = (-b + sqrt(b^2 - 4ac))/2a 2. The way in which it may be determined that the ray misses the sphere is that a. both values of t are negative b. a = 0 c. b^2 < 4ac 3. The ray will touch the sphere at only a single point if and only if a. a = 0 b. b^2 = 4ac c. b = 0 Suppose the viewpoint is located at (0, 0, 5), a sphere of radius = 2 has center (0, 0, -4) and a ray is fired in the direction (0, 0, -1) 4. Give the (x, y, z) coordinates of the hitpoint ( , , ) 5. Provide the unit length normal vector at the location of the hit: ( , , ) Computer Science 215 Quiz B Name ______________________ 1. Which of the following best characterizes what happens when a program attempts to invoke a function that is defined in another module but for which no prototype definition is supplied: (suppose main.c invokes function adder() in adder.c and the compile command is: gcc -g main.c adder.c) a. it will cause a syntax error b. it will cause an error at link at compile time because the time because the linker won't function name is not defined be able to find adder() c. it will always work fine d. it will only work if adder() returns int and its parameters are of the correct type 2. Suppose "funptr" is a properly declared pointer to functions having two int parameters and returning int. The correct way to cause it to point to "adder" is: a. funptr = adder; b. funptr = &adder; c. *funptr = adder; d. funptr = adder(); 3. After the pointer is correctly initialized, the proper way to invoke the function adder through the pointer is: a. s = funptr(3, 4); b. s = (*funptr(3, 4)); c. s = (*funptr)(3, 4); d. s = *(funptr)(3,4); 4. To tell gcc to produce a .o file from a .c file and NOT run the linker gcc should be invoked as: a. gcc -g test.c b. gcc -o test.o test.c c. gcc -Dcompile test.c d. gcc -c test.c 5. Suppose the following debugging code is present in image.c #ifdef DBG_PIX fprintf(stderr, "\n %4d %4d ", x, y); #endif Write the gcc command that should be used to create image.o with the debug print enabled. Computer Science 215 Quiz C Name ______________________ 1. In the procedural shader model described last time in class which of the following functions were performed by pplane_init(). (Select ALL that apply). a. allocate a new structure of b. modify the getamb() function pointer type pplane_t in the obj_t c. invoke plane_init() to construct an instance of a plane_t 2. For objects of type plane_t and sphere_t the getamb function pointer in the obj_t a. is set to NULL b. points to a default function that will set the intensity vector to (0.0, 0.0, 0.0) c. points to a default function that will set the intensity vector to the ambient component of obj->material. 3. Suppose the location of the hit point for a ray is denoted (vx, vy, vz). A procdural shader that is producing a tiled floor should be a function of: a. vx and vy but not vz b. vx and vz but not vy c. vy and vz but not vz d. vy only 4. Suppose a table of shaders is defined as follows: static void (*plane_shaders[])(obj_t *obj, double *intensity) = { pplane0_amb, pplane1_amb, pplane2_amb }; The correct way to automatically compute the number of entries in the table is: a. #define NUM_SHADERS sizeof(plane_shaders / (void *)) b. #define NUM_SHADERS sizeof(plane_shaders[0])/sizeof(void *) c. #define NUM_SHADERS sizeof(plane_shaders)/sizeof(void *) d. #define NUM_SHADERS sizeof(void *) / sizeof(plane_shaders) 5. For a procedural shader to produce a "bull's eye" target of concentric rings on a "back wall" the intensity vector should be filled in as a function of: a. (int) sqrt(vx^2 + vy^2) b. (int) sqrt(vx^2 + vz^2) c. (int) sqrt(vx^2) + sqrt(vy^2) d. (int) sqrt(vx^2) + sqrt(vz^2) (The notation vx^2 means vx squared and NOT vx xor 2 here). Computer Science 215 Quiz D Name ______________________ 1. If a C program mallocs an area of memory and fails to free it, a. A garbage collector built b. The OS will reclaim all of the into the C language will memory used by the program including reclaim it unfreed malloc'd areas when the program exits. c. The memory will remain unusable d. The memory will remain permanently until the system is rebooted allocated and the computer will eventually have to be sent back to the factory for memory replacement 2. The object_init() function is resposible for dynamically allocating new obj_t structures. a. it must use malloc() b. it must use alloca() c. it may use either one. 3. Assuming "lst" points to the head of one of our object lists, which best characterizes the following code fragment: obj_t *temp = malloc(sizeof(obj_t)); temp = lst->head; a. it will cause a memory leak b. it will cause a seg fault c. it is the correct way to set temp to point to the first object in the list. 4. Suppose a new object structure is being created and the object structure is allocated as follows: newobj = malloc(sizeof(obj_t)); After the new object pointer has been safely linked into the object list, before returning the routine that allocated the object a. should free(newobj); b. MUST free(newobj); c. MUST NOT free(newobj); 5. When alloca() is used to allocate memory in a function, a. free() MUST be used to release b. free() MUST NOT be used the memory BEFORE the function to free the memory returns c. free() may optionally be used Computer Science 215 Quiz E Name ______________________ 1. The correct way to declare an integer array with 3 rows and 4 columns is: a. int t[4][3]; b. int t[4, 3]; c. int t[3][4]; d. int t[3, 4]; 2. If am creating a function to process an array having 3 rows and 4 colums, circle ALL off the following approaches that will generate a compiler error if I try to access t[1][1]. a. int fun(int t[][]) b. int fun(int t[3][]) c. int fun(int t[][4]) d. int fun(int t[3][4]) 3. Suppose I have an array declared as int w[3][3]; and I want to pass it as a parameter to a function to which expects a 3 x 3 array as input. . Which of the following will NOT generate compiler warnings (circle all that will not). a. fun1(w[0]); b. fun1(w); c. fun1(&w[0][0]); d. fun1(&w[0]); 4. Suppose an array is declared as int x[4][3]. Which of the following pairs of values will occupy adjacent words in memory? (Circle all that apply) a. x[1][0] and x[2][0] b. x[1][0] and x[1][1] c. x[1][1] and x[2][2] d. x[2][2] and x[3][0] 5. The number of bytes required to store int x[4][3] on an intel x86 machine is: a. 4 * 4 b. 4 * 7 c. 4 * 12 d. 4 * 6 Computer Science 215 Quiz F Name ______________________ 1. Given three points, P, Q, and R, the normal to the plane that three points define is given by: (x means Cross Product) a. P x R b. (P - Q) x R c. (P - Q) x (R - Q) d. Q x (P - R) 2. The cross product (0, 1, 0) and (0, 0, 1): a. (0, 1, 1) b. (0, 0, 1) c. (0, 1, 0) d. (1, 0, 0,) 3. The projection of a unit vector V on another unit vector N is given by: a. V dot N b. (N dot V) N c. (V dot N) V d. (N x V) N 4. Which of the following is NOT always an attribute of a rotation matrix a. its rows are mutually b. It is the identity matrix orthogonal c. its inverse is its d. Its rows and columns are transpose unit vectors 5. The projection of a unit vector V on a plane whose normal is N given by: a. V - (N dot V) V b. V - (N dot V) N c. (V dot N) V - V d. (N x V) N Computer Science 215 Quiz G Name ______________________ Complete the output of the following program: int y = 11; int main( ) { printf(" y = %d \n", y); int y = 12; if (1) { int y, z; y = 92; printf(" y = %d \n", y); } printf(" y = %d \n", y); } 1. y = 2. y = 3. y = void f1(void) { int x; printf("x = %d \n", x); x = 55; } void f2(void) { int z; printf("z = %d \n", z); z = 102; } main() { f1(); f2(); f1(); } Complete the LAST TWO lines that will be printed by the above program: 4. z = 5. x = Computer Science 215 Quiz H Name ______________________ Consider the following function: int adder(int a, int b) { int sum; 1. The variable "a" will be accessed as: a. 8(%ebp) b. 12(%esp) c. -8(%ebp) d. -8(%esp) 2. The variable "sum" will be accessed as: a. 4(%ebp) b. 4(%esp) c. -4(%ebp) d. -4(%esp) 3. The value that resides on the stack between the return address and the first local variable is: a. the address of the start b. A copy of ESP at the time of the function adder adder() was invoked c. A copy of EBP at the time d. The value specified in adder was invoked. the return() statement. 4. Suppose that static int x; is declared at the <> of model.c in your raytracer. The value of x may be accessed a. only within model.c b. by any code in any module c. in any module in which extern int x; appears at the top. 5. Declaring a function static in model.c static int adder(int x, int y) a. causes the return value of b. means that the function to live on the extern int adder(int x, int y); heap instead of the stack must be included in other modules that want to invoke adder. c. makes it impossible to invoke adder() from modules other than model.c Computer Science 215 Quiz I Name ______________________ 1. How many bytes of storage does an instance of the following union occupy: union u_type { double d; int x; float y; char c; char z[6]; }; 2. What two characters (in order) will the following program print: int main( int argc, char **argv) { printf("%c %c \n", *(*(argv + 2)), *(*(argv + 1) + 1)); } a.out Hello World 3. Given the following declarations answer "T" or "F" depending upon whether the assignment statment is syntactically correct obj_t o; obj_t *po; obj_t *ppo; ____ a. po = *ppo; ____ b. po = &o; ____ c. *ppo = &po; ____ d. ppo = &po; 4. Suppose ppo is of type obj_t **. The assignment ppo += 1; will cause the true value of ppo to be incremented by a. 1 b. sizeof(obt_t) b. sizeof(obj_t *) Computer Science 215 Quiz J Name ______________________ 1. Suppose class x_t is being defined. The correct way to declare a prototype for its DEFAULT constructor is: a. class x_t b. class x_t { { public: public: x_t x_t(); int x_t(); c. class x_t d. class x_t { { public: public: x_t(); x_t x_t(const x_t); 2. Which of the following ways of overloading load_view() are correct: class view_t class view_t { { public: public: int load_view(int); int load_view(int); int load_view(char); void load_view(int); a. The one on the left b. The one on the right c. Both of them are correct 3. Suppose class view_t has a method named load_view() and an instance of the class is created as: view_t v; The proper way to invoke the load_view() method is: a. v->load_view(); b. v.load_view(); c. v::load_view(); d. load_view(); 4. Suppose class view_t has a method named load_view() and an instance of the class is created as: view_t *v new view_t; The proper way to invoke the load_view() method is: a. v->load_view(); b. v.load_view(); c. v::load_view(); d. load_view(); 5. Which of the following is the correct way to create an implementation of load_view a. int view_t:load_view(int x) b. int view_t::load_view(int x) c. int view_t.load_view(int x) d. view_t::int load_view(int x) Computer Science 215 Quiz K Name ______________________ 1. In the new linked list classes described in class last time, in the list_add method of the list_t class which of the following is the proper way to add a new link_t named "link" to an non-empty list_t; a. last = link; b. last->set_next(link); last->set_next(link); last = link; c. the order in which the two statements are executed is irrelevant 2. The next element of a link_t class points to: a. an obj_t structure b. a list_t structure c. a link_t structure 3. The "next" element of a link_t class will be assigned a new value a. only by the link_t constructor b. every time the list is processed c. when the link_t is constructed and exactly one later time. 4. The proper way to declare a polymorphic function in the obj_t class is: a. virtual void getamb(double *); b. virtual void getamb(double *){}; c. both ways are equivalent 5. The hitloc and normal elements of the obj_t are "protected". This is done to: a. prevent methods other than b. allow all methods access to those internal to the obj_t the variables from accessing them. c. allow method is classes derived from the obj_t to access them Computer Science 215 Quiz L Name ______________________ 1. Suppose a tiled plane class, tplane_t, is a derived from class plane_t which is in turn derived from classes obj_t and material_t. The correct way to express this relationship is: a. class tplane_t: public obj_t, public material_t b. class tplane_t: public plane_t c. class tplane_t: public obj_t, public material_t, public plane_t 2. The tplane_t constructor begins as follows tplane_t::tplane_t( FILE *in, FILE *out, int otype, int oid) : plane_t(in, out, otype, oid) if the : plane_t(in, out, otype, oid) text is deleted a. the plane_t constructor will no b. there will be no difference at longer be called when a tplane_t all in the behavior of the is created program c. a plane_t constructor will be called but it will be the default constructor instead of the one with 4 parameters 3. When a new tiled plane is created via the "new" operator, the order in which the body of the constructors will execute is: a. tplane_t, plane_t, material_t, b. obj_t, material_t, plane_t obj_t tplane_t c. plane_t, tplane_t d. only the tplane_t constructor will execute automatically 4. Suppose the tplane_t::dump_obj() function contains the following code: void tplane_t::dump_obj( FILE *out) { plane_t::dump_obj(out); a. The flane_t:: prefix in the b. the plane_t:: prefix serves line shown will create a only to document whats going on. syntax error Removing it will have no effect on program behavior c. Removing the plane_t:: prefix will cause an infinite recursion loop 3. The particular superclass constructor to be used when an instance of the derived class is created is specified a. along with the inheritance b. in the class definition of the in the class definition of superclass the derived class. c. in the definition of the d. in the definition of the constructor method of the constructor method of the superclass derived class. Computer Science 215 Quiz M Name ______________________ 1. In the approach to anti-aliasing that was discussed in class, the number of rays traced per pixel a. is still one ray per pixel b. is some constant number > 1 c. is a random number of rays 2. The x-dimension size (in WORLD COORDINATES) of the "box" on the screen through which a randomized ray used in antialiasing passes is: a. world_x_size (world size of b. win_x_size (number of window the window in x dimension) pixels in x dimension) c. win_x_size / world_x_size d. world_x_size / win_x_size Consider the diagram illustrating ray reflection: Assume that N represents the surface normal and V the direction of the reflected ray. 3. The vector shown as a dashed line is given by: a. N dot U b. N (U dot V) c. N (U dot N) d. 2 N (U dot N) 4. The V vector is a. N (U dot N) b. 2 N (U dot N) - U c. (N dot U) N d. none of the above 5. When a ray is reflected from the surface as an object, what object(s) should be EXCLUDED as possible next hit objects. a. all objects with specular b. the object that reflected reflectivity the ray c. no objects Computer Science 215 Quiz N Name ______________________ 1. In the metaphoric discussion of how best to "operate" on an existing program so as to add new functionality, the recommended surgical tool was: a. meat axe b. scalpel c. chain saw d. "suitcase" nuclear weapon 2. In the C++ raytracer pixmap_t, ray_t and pixel_t are related as follows: (creates means: uses "new" to create an instance of) a. pixel_t creates pixmap_t b. pixmap_t creates ray_t which which creates ray_t creates pixel_t c. ray_t creates pixel_t d. pixmap_t creates pixel_t which which creates pixmap_t creats ray_t 3. Suppose an image of 1000 x 1000 pixels is created with 10 antialised samples per pixel and an average of 4 specular bounces per ray. The total number of ray_t's created and destroyed is closest to: a. 5 b. 50 c. 50,000 d. 50,000,000 4. Which best described the inheritence relationship (if any) between the pixel and pixmap classes as described in class: a. pixel is derived from pixmap b. pixmap is derived from pixel c. neither is derived from the other.