{"id":217634,"date":"2018-09-15T22:59:05","date_gmt":"2018-09-15T22:59:05","guid":{"rendered":"http:\/\/localhost\/wordpress\/index.php\/2018\/09\/15\/gsp-125-midterm-exam\/"},"modified":"2018-10-24T08:48:52","modified_gmt":"2018-10-24T08:48:52","slug":"gsp-125-midterm-exam","status":"publish","type":"post","link":"https:\/\/www.benedictsol.com\/blogs\/gsp-125-midterm-exam\/","title":{"rendered":"GSP 125 Midterm Exam"},"content":{"rendered":"<p>1. Accidentally inheriting from the same class twice causes terrible ambiguity, and is known as (Points : 2)\t\u00a0 \u00a0 \u00a0 \u00a0inheritance overload.\t\u00a0 \u00a0 \u00a0 \u00a0the dreaded diamond of death.\t\u00a0 \u00a0 \u00a0 \u00a0Von Neumann bottleneck.\t\u00a0 \u00a0 \u00a0 \u00a0There is nothing wrong with inheriting the same class more than once.\t\u00a0\tQuestion 2. 2. Creating classes in separate .h and .cpp files is good because (Points : 2)\t\u00a0 \u00a0 \u00a0 \u00a0moving code to separate files is good design (separation of concerns).\t\u00a0 \u00a0 \u00a0 \u00a0separating declaration from definition allows de-coupling of dependencies.\t\u00a0 \u00a0 \u00a0 \u00a0many smaller files are easier to maintain by teams of programmers.\t\u00a0 \u00a0 \u00a0 \u00a0All of the above\t\u00a0\tQuestion 3. 3. Virtual methods are resolved at runtime by using a (Points : 2)\t\u00a0 \u00a0 \u00a0 \u00a0dynamic list.\t\u00a0 \u00a0 \u00a0 \u00a0virtual table.\t\u00a0 \u00a0 \u00a0 \u00a0vector.\t\u00a0 \u00a0 \u00a0 \u00a0haystack.\t\u00a0\tQuestion 4. 4. Allowing many different types to be treated in the same way is called (Points : 2)\t\u00a0 \u00a0 \u00a0 \u00a0polymorphism.\t\u00a0 \u00a0 \u00a0 \u00a0multitypecasting.\t\u00a0 \u00a0 \u00a0 \u00a0deep-copy.\t\u00a0 \u00a0 \u00a0 \u00a0virtual.\t\u00a0\tQuestion 5. 5. Heap memory is where (Points : 2)\t\u00a0 \u00a0 \u00a0 \u00a0global variables and raw machine code are stored.\t\u00a0 \u00a0 \u00a0 \u00a0local variables and execution of instructions is kept track of.\t\u00a0 \u00a0 \u00a0 \u00a0dynamic memory is allocated to.\t\u00a0 \u00a0 \u00a0 \u00a0None of the above\t\u00a0\tQuestion 6. 6. Memory leaks in a computer program are (Points : 2)\t\u00a0 \u00a0 \u00a0 \u00a0not a big deal because operating systems clean up all program memory.\t\u00a0 \u00a0 \u00a0 \u00a0easy to find and debug in C and C++.\t\u00a0 \u00a0 \u00a0 \u00a0difficult and important to manage in C and C++.\t\u00a0 \u00a0 \u00a0 \u00a0a problem in every programming language.\t\u00a0\tQuestion 7. 7. Virtual functions have a cost when compared to normal (statically bound) functions; specifically, they are (Points : 2)\t\u00a0 \u00a0 \u00a0 \u00a0slower and less optimizable.\t\u00a0 \u00a0 \u00a0 \u00a0less dynamic.\t\u00a0 \u00a0 \u00a0 \u00a0unusable with polymorphism.\t\u00a0 \u00a0 \u00a0 \u00a0more difficult to read than extern or static functions.\t\u00a0\tQuestion 8. 8. The explicit keyword (Points : 2)\t\u00a0 \u00a0 \u00a0 \u00a0labels data as being volatile.\t\u00a0 \u00a0 \u00a0 \u00a0prevents constructors from automatically being called by implicit typecasting.\t\u00a0 \u00a0 \u00a0 \u00a0marks a method as an override of a polymorphic base.\t\u00a0 \u00a0 \u00a0 \u00a0identifies a variable that can be referenced but is defined in another compilation unit.\t\u00a0\tQuestion 9. 9. Preprocessor macros (Points : 2)\t\u00a0 \u00a0 \u00a0 \u00a0should be avoided if other langauge features will work just as well.\t\u00a0 \u00a0 \u00a0 \u00a0can easily confuse other progammers not familiar with your macro.\t\u00a0 \u00a0 \u00a0 \u00a0should be undefined after use to avoid polluting the global namespace.\t\u00a0 \u00a0 \u00a0 \u00a0All of the above\t\u00a0\tQuestion 10.10. Which piece of the C\/C++ compile tool chain arranges compiled code into the final executable? (Points : 2)\t\u00a0 \u00a0 \u00a0 \u00a0Preprocessor\t\u00a0 \u00a0 \u00a0 \u00a0Compiler\t\u00a0 \u00a0 \u00a0 \u00a0Linker\t\u00a0 \u00a0 \u00a0 \u00a0Debugger<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1. Accidentally inheriting from the same class twice causes terrible ambiguity, and is known as (Points : 2) \u00a0 \u00a0 \u00a0 \u00a0inheritance overload. \u00a0 \u00a0 \u00a0 \u00a0the dreaded diamond of death. \u00a0 \u00a0 \u00a0 \u00a0Von Neumann bottleneck. \u00a0 \u00a0 \u00a0 <a href=\"https:\/\/www.benedictsol.com\/blogs\/gsp-125-midterm-exam\/\" class=\"read-more\">Read More &#8230;<\/a><\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[],"tags":[],"class_list":["post-217634","post","type-post","status-publish","format-standard","hentry"],"_links":{"self":[{"href":"https:\/\/www.benedictsol.com\/blogs\/wp-json\/wp\/v2\/posts\/217634","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.benedictsol.com\/blogs\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.benedictsol.com\/blogs\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.benedictsol.com\/blogs\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.benedictsol.com\/blogs\/wp-json\/wp\/v2\/comments?post=217634"}],"version-history":[{"count":0,"href":"https:\/\/www.benedictsol.com\/blogs\/wp-json\/wp\/v2\/posts\/217634\/revisions"}],"wp:attachment":[{"href":"https:\/\/www.benedictsol.com\/blogs\/wp-json\/wp\/v2\/media?parent=217634"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.benedictsol.com\/blogs\/wp-json\/wp\/v2\/categories?post=217634"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.benedictsol.com\/blogs\/wp-json\/wp\/v2\/tags?post=217634"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}