Sample/practice exam 2015, questions and answers - Midterm PDF

Title Sample/practice exam 2015, questions and answers - Midterm
Course Principles of Computer Science
Institution University of Saskatchewan
Pages 7
File Size 146.1 KB
File Type PDF
Total Downloads 25
Total Views 135

Summary

midterm ...


Description

CMPT 115 Practice Midterm Examination Part A: C++ Programming Question A.1 Indicate whether each statement is TRUE or FALSE. (a) In C++, the * operator has at least three distinct meanings depending on the context. (a) Solution: TRUE (multiplication, declare pointer, dereference operator) (b) When implementing an ADT in C++, the function prototypes for ADT operations should not appear in the ADT’s header (.h) file. (b) Solution: FALSE (the header is exactly where they should go) (c) In C++, memory that is allocated on the heap using new is automatically freed when the function which allocated the memory returns. (c) Solution: FALSE (new’ed memory can only be released by delete) (d) A file pointer fin can be used only to read a full line of input from a text file, one line at a time. (d) Solution: FALSE (It can read until the next whitspace) (e) The variable declaration char *foo[] declares a pointer to an array of characters. (e) Solution: FALSE (It declares an array of character pointers) (f) A struct can contain any number of fields. (f)

Solution: TRUE (g) The open() function can only be used to open files for reading. (g) Solution: FALSE (It also can open files for writing, appending) (h) The function header student *func( int z ); declares a function that returns a pointer to a structure called ’student’. (h) Solution: TRUE (i) The command cout...


Similar Free PDFs