Download CSE 240 Midterm Exam with 100% Correct Answers 2023 and more Exams Advanced Education in PDF only on Docsity! CSE 240 Midterm Exam with 100% Correct Answers 2023 Stored Program Concept (von Neumann machine) is one of the most fundamental concepts in computer science. What programming paradigm most closely follows this concept? - Correct Answer-imperative A set of basic principles, concepts, and methods for how a computation or algorithm is expressed - Correct Answer-paradigm The programming paradigm that expresses computation by fully-specified and fully- controlled manipulation of named data in a stepwise function - Correct Answer- imperative Another term for the imperative paradigm - Correct Answer-procedural The programming paradigm that is basically the same as the imperative paradigm except that related variables and operations on variables are organized into classes of objects - Correct Answer-object-oriented The programming paradigm that expresses computation in terms of mathematical functions - Correct Answer-functional Another term for the functional paradigm - Correct Answer-applicative The programming paradigm that expresses computation in terms of logic predicates - Correct Answer-logic Another term for the logic paradigm - Correct Answer-declarative If you teach someone to make a pizza, you are in fact teaching (functional, imperative) programming. - Correct Answer-imperative If you teach someone to order a pizza from a restaurant, you are in fact teaching (functional, imperative) programming. - Correct Answer-functional Because of hardware constraints, early programming languages emphasized _____. - Correct Answer-readability The main idea of structured programming is to A) increase the types of control structures, B) make programs execute faster, C) reduce the types of control structures, D) use BNF to define the syntactic structure. - Correct Answer-C A meta language that can be used to define the lexical and syntactic structures of another language - Correct Answer-Backus-Naus Form Which programming language allows the mixed use of data types? (Ada, C, Java, All of them) - Correct Answer-C In the layers of programming structure, which layer performs type checking? - Correct Answer-contextual Which programming structure defines the program semantics before dynamic execution? - Correct Answer-contextual Another term for contextual structure - Correct Answer-static semantics Which programming structure describes the meaning of a program during the execution? - Correct Answer-semantic structure Which programming structure defines the grammar of forming sentences or statements using the lexical units? - Correct Answer-syntactic structure Which programming structure defines the vocabulary of a language? - Correct Answer- lexical structure Interpretation is not efficient if A) multi-module programming is used, B) the difference between source and destination is small, C) the source program is small, or D) the source program is written in an assembly language. - Correct Answer-A A machine language with sophisticated use of mnemonics - Correct Answer-assembly language The direct execution of one statement at a time sequentially by the interpreter - Correct Answer-interpretation First translates all the statements of a program into assembly language code or machine code before any statement is executed - Correct Answer-compilation (Inclining, Macro) is a suggestion to the compiler, while (inlining, macro) will be enforced. - Correct Answer-Inlining, macro The phase prior to the code translation to the assembly or machine code - Correct Answer-preprocessing Macros processing takes place during which phase? - Correct Answer-preprocessing Assume a program requires 20 lines of machine code and will be called 10 times in the main program. You can choose to implement it using a function definition or a macro Any explanatory text embedded in the program - Correct Answer-comments A graphic form of notation often used to supplement the readability of BNF notation - Correct Answer-syntax graph Another term for syntax graph - Correct Answer-railroad tracks A declaration of an identifier for which the programmer has not yet given a complete definition - Correct Answer-forward declaration Statements in a function form a conceptual unit - Correct Answer-abstraction Forward declaration in modern programming practice A) is never necessary, B) is not required if <iostream> is included, C) is useless, or D) provides a level of abstraction. - Correct Answer-D C language does not have a Boolean type because A) Boolean values can be represented as integers, B) C is not designed to handle logic operations, C) C uses strong type checking, or D) C++ already defined a Boolean type. - Correct Answer-A Two functions are mutually recursive functions if A) each function calls itself, B) one function is defined within the other function, C) they are independent of each other, or D) they call each other. - Correct Answer-D Assume that a string is declared as char str[] = "alpha", what is the return value of sizeof(str)? - Correct Answer-6 Assume that two pointers are declared as char *str1 = "alpha", *str2. Which of the following assignment statements will lead to a semantic error? A) str2 = str1, B) str2 = 0, C) str1 = str1 + 1, or D) *str2 = "world" - Correct Answer-D Which of the following declarations will cause a compilation error? A) char s[5], B) char s[3] = "hello", C) char s[], or D) char s[] = {'s', 't', 'r'} - Correct Answer-C Given a declaration: int i = 25, *j = &i, **k = &j; which of the following operations will change the value of variable i? A) j++, B) k++, C) (*k)++, or D) (**k)++ - Correct Answer- D Given a declaration: int i = 25, *j = &i, **k = &j; which of the following operations will cause a compilation error? A) i++, B) (&i)++, C) (*j)++, or D) (**k)++ - Correct Answer-B What is the maximum number of padding bytes that a compiler can add to a structure? - Correct Answer-more than 3 What parameter-passing mechanism cannot change the variable values in the caller? - Correct Answer-call-by-value The parameters we used when we declare a function - Correct Answer-formal parameters The values or variables we used to substitute for the formal parameters when we call a function - Correct Answer-actual parameters The parameter-passing mechanism in which a formal parameter is a local variable in the function - Correct Answer-call-by-value The parameter-passing mechanism in which the formal parameter is an alias name of the actual parameter - Correct Answer-call-by-alias Name the other two terms for call-by-alias - Correct Answer-call-by-reference, call-by- variable The parameter-passing mechanism in which the address of the actual parameter is passed into a local variable of the function - Correct Answer-call-by-address Name the other term for call-by-address - Correct Answer-call-by-pointer What parameter-passing mechanism requires the actual parameter to be a variable? - Correct Answer-call-by-alias Given the forward declaration: void foo(int m, int &n); What parameter passing is used? - Correct Answer-call-by-alias What type of recursive function is structurally equivalent to a while-loop? - Correct Answer-tail-recursion How many bits are in a byte? - Correct Answer-8 Temporary storage in the CPU that holds the data the processor is currently working on - Correct Answer-register Holds the program instructions and the data the program requires - Correct Answer- RAM What are the four aspects of a variable? - Correct Answer-value, location, address, name What are the three different ways to introduce constants in C/C++? - Correct Answer- macro, const qualifier, enumeration constant Can a constant defined by const ever be modified? - Correct Answer-No A region of shared memory that, over time, can contain different types of values - Correct Answer-union type variable What parameter passing mechanism is used when the parameter is a variable? - Correct Answer-call-by-value What parameter passing mechanism is used when the parameter is an address? - Correct Answer-call-by-alias What parameter passing mechanism is used when the parameter is a pointer? - Correct Answer-call-by-address What is the keyword used to create a structure? - Correct Answer-struct A variable that is outside all functions - Correct Answer-global Explicit type conversion - Correct Answer-typecasting