3
3
7. In contrast to Web 1.0, what is the key function of Web Web is the com-
2.0? puting platform
14. If your program was designed to print "Hello World" Semantics error
ten (10) times, but during execution, it printed eleven
(11) times. What type of error is it?
15. What does the | (pipe) symbol in a BNF rule mean? It is an or state-
ment. Choose one
of the options.
2 / 22
CSE240 - quizzes final
Study online at https://quizlet.com/_6j9zbz
<expr> ::= <variable> <operator> <variable> | ( <expr>
) <operator> ( <expr> )
a = x + y; b = s * t; c = w + v;
3 / 22
CSE240 - quizzes final
Study online at https://quizlet.com/_6j9zbz
<expr> ::= <variable> <operator> <variable> | ( <expr>
) <operator> ( <expr> )
<assign> ::= <variable> = <expr>;
<statements> ::= <assign> | <assign> <statements>
a = b + c + d;
int main()
{
int x = 10;
4 / 22
CSE240 - quizzes final
Study online at https://quizlet.com/_6j9zbz
int y = 9;
int z = func(x, y);
}
28. Where is the main() function located in a C or C++ outside any class
program?
30. Which of the following types is a C++ type, but NOT a bool
C type?
31. What is NOT the purpose (functionality) of the for- to allow functions
ward declaration (prototype)? to return different
types of values
32.
5 / 22
CSE240 - quizzes final
Study online at https://quizlet.com/_6j9zbz
During data declaration, a name is binded to a mem- Data Type
ory location, what else can be identify as part of this Scope
process? Qualifier
35. Given the C declaration: char s1[4], s2[ ] = "hello"; if a The result is s1
string copy function strcpy(s1, s2) is executed, what will contain the
will happen? string "hell", and
the follwing two
byte loactions will
contain 'o' an '\0'.
36. Given: 40
char: 1
short: 2
int: 4
long: 4
float: 4
double: 8
37. Given the following code and considering things like 'x'
ASCII values and pointer addresses:
6 / 22
CSE240 - quizzes final
Study online at https://quizlet.com/_6j9zbz
int num1 = 5; //addressed at 1767612
*iPtr = num3 * 8;
*chPtr = *iPtr;
38. Given the following code and considering things like 1767588
ASCII values and pointer addresses:
*iPtr = num3 * 8;
*chPtr = *iPtr;
41. C/C++ has 2 pointer operators, which operator repre- Asterisk (*)
sents the name of the address? (Commonly refer as
l-value.)
42. Given this snippet of code, what is the value of x after 100
executing the last statement?
y = &x;
*y = 100;
y = y + 1;
43. Given this snippet of code, determine which of the fol- x = array;
lowing options will change the text in array to "Hello
Doe" after execution. (Check all that applies.) *(x + 6) = 'D';
---------------------
8 / 22
CSE240 - quizzes final
Study online at https://quizlet.com/_6j9zbz
char array[] = "Hello Joe"; x = &array[0];
char *x; x = x + 6;
*x = 'D';
9 / 22
CSE240 - quizzes final
Study online at https://quizlet.com/_6j9zbz
double d2 = 2.25; //addressed at 1374360
double d3 = 3.14; //addressed at 1374344
After these statements:
46. Given this snippet of code, what is the value of x after 1000
executing the last statement?
y = &x;
z = &y;
**z = 1000;
10 / 22
CSE240 - quizzes final
Study online at https://quizlet.com/_6j9zbz
char a[2][3] = { { 'c', 'a', 't'}, { 'd', 'o', 'g'} };
int i, j;
for (i = 0; i<2 ; i++) {
for (j = 0; j<3; j++)
printf("%c", a[i][j]);
}
char a[2][4] = { { 'c', 'a', 'r', 'b' }, { 'i', 'k', 'e', '\0' } }; char
*p = &a[0][0]; while (*p != '\0') { printf("%c", *p); p++; }
#define size1 10
const int size2 = 20;
char a1[size1];
char a2[size2];
typedef enum {Sun, Mon, Tue, Wed, Thu, Fri, Sat} days;
days x = Mon, y = Sat;
while (x != y) { x++; }
y++;
printf("x = %d, y = %d", x, y);
54.
11 / 22
CSE240 - quizzes final
Study online at https://quizlet.com/_6j9zbz
Which of the following coding practice can lead to a Keep the charac-
higher memory efficiency (use fewer padding bytes) ter type variables
in defining a structure? together.
55. When is padding required for a structure type vari- When the struc-
able? ture contains a
word-type vari-
able, such as in-
teger, float, and
pointer, and the
total number of
bytes is not a mul-
tiple of four.
56. The size (number of bytes) of a structure-type vari- changing the or-
able can be changed by the following factors. Select ders of the mem-
all that apply. bers in the struc-
ture.
adding a member
into the structure.
57. When will the buffer be created? When the file op-
eration fopen is
performed.
12 / 22
CSE240 - quizzes final
Study online at https://quizlet.com/_6j9zbz
60. Given the information below, how will you access the x->name;
name for a terminal node pointed to by x?
struct Terminal {
char name[30];
char location[32];
struct Terminal* next;
} *x;
struct Terminal {
char name[30];
char location[32];
struct Terminal* next;
} *x;
struct Terminal {
char name[30];
char location[32];
struct Terminal* next;
} x;
63. Assume that the search function of a linked list is the address of a
specified by terminal node
0
struct Terminal* search();
64. Assume that you want to delete the entire linked list head = null;
pointed to by head. Which of the following deletion
operation will cause the most garbage of memory?
65.
13 / 22
CSE240 - quizzes final
Study online at https://quizlet.com/_6j9zbz
Given the information below, which of the follow- x = head;
ing snippet of codes will print every terminal in the
linked-list without any side-effects of changing the while(x != NULL) {
state. Assume head is the only reference to the
linked-list and there are more than one terminal in the printf("%s - %s",
list. x->name, x->loca-
tion);
struct Terminal { x = x->next;
char name[30]; }
char location[32];
struct Terminal* next;
} *head, *x;
66. Given the information below, which of the following p = (struct con-
snippet of codes will insert a new node in the second tact *) malloc(size-
place in the linked-list. Assume the linked-list con- of(struct contact));
tains already at least one node.
...
struct Terminal {
char name[30]; p->next =
char location[32]; head->next;
struct Terminal* next;
} *head, *p, *q; head->next = p;
67. What is the key difference between a static variable They have differ-
and a global variable? ent visibility
68. If a function calls another function, the local variables different stack
in these two functions use the memory from frames.
72. What is the best way of deleting a linked list of object Use a loop to
in C++? delete every ob-
ject in the linked
list.
74. What members of a base class can be redefined in the virtual members
derived classes?
76. Consider a path from the root to a leaf of a class tree The class at the
based on the inheritance. Which class has the most leaf of the tree
class members?
77. If you want to create a linked list of Container nodes, A pointer to Publi-
which can contain Publication node, Book node, The- cation node
sis node, and Report node, what type of pointer
should be declared in the Container to point to all
these nodes?
78. Defining a virtual function in class means that the can be redefined
function in its child classes.
79. If the relation between two C++ classes can be best contain one class
described as "has-a" relation, we should in the other (con-
tainment).
80. Given the following class definition and the variable x.empl.id = 12345;
declaration:
class employee
char *name;
long id;
15 / 22
CSE240 - quizzes final
Study online at https://quizlet.com/_6j9zbz
}
class manager {
employee empl;
char* rank;
}x
81. What features are supported in C++? Select all that Function over-
apply. loading
Operator over-
loading
Virtual operator
Virtual function
84. Given this snippet of code, identify what is the size-n void
(whole) problem? deleteList(struct
contact* node)
void deleteList(struct contact* node) {
if (node != NULL) {
deleteList(node->next);
free(node);
} else
return;
86. Given this snippet of code, identify what is the size-m deleteList(node->next)
(sub-divided) problem?
if (node != NULL) {
deleteList(node->next);
free(node);
} else
return;
88. The Golden Rule of Recursion is "All base cases must False
make progress towards a recursive case."
89. Given a Binary Search Tree class with the properties: if(item > cur-
rent->data)
Node* root; return
And the node defined as: helpFindIt(cur-
rent->right, item)
struct Node
{ if(item < cur-
int data; rent->data)
Node* left; return
Node* right; helpFindIt(cur-
} rent->left, item)
I have a method:
91. The data stored in a binary search tree is sorted, if the inorder
tree is traversed in
92. The search algorithm will be more efficient if a binary a balanced binary
search tree is tree.
93. Consider an array, a linked list, and a binary search binary search tree
tree. Which data structure requires fewest compar-
isons in average to search an element stored in the
data structure?
95. In Scheme, the form (symbol-length? 'James) will re- an error message
turn:
96. One of the major differences between the imperative have side-effect.
and functional programming languages is that the
functional programming languages do NOT
18 / 22
CSE240 - quizzes final
Study online at https://quizlet.com/_6j9zbz
98. What notation requires parentheses in order to cor- infix notation
rectly define the order of computation?
100. What functional feature does the code below best procedures are
exhibit? first class object.
101. Given this procedure, what is the return result? "I'm a number"
(define (guess value)
(cond ((number? value) "I'm a number")
((char? value) "I'm a character")
((integer? value) "I'm a integer")))
(guess 10)
105. For functional programming languages, the scope of is in the body part
a local name of the declaration
or definition.
((lambda (x)
((lambda (x y)
19 / 22
CSE240 - quizzes final
Study online at https://quizlet.com/_6j9zbz
(+ x y))
4 (* 6 x)))
3)
107. What is the expected result for this expression (in #\o
Scheme)?
'(x)
20 / 22
CSE240 - quizzes final
Study online at https://quizlet.com/_6j9zbz
111. Given the Scheme code as follows. What is the out- (1 0 1 0 1 0)
put?
(define reduce
(lambda (op base x)
(if (null? x)
base
(op (car x) (reduce op base (cdr x)) )))
)
113. Compare the follow two Scheme forms: (cons '(1 2) '(4 5))
(append '(1 2) '(4 5)) and (cons '(1 2) '(4 5)). returns '((1 2) 4 5)
114. Which predicate logic matches most closely with this listensto(bill, mu-
statement? sic); listensto(bill,
news).
"Bill listens to music or news."
117. A prolog program may contain: (Select all that apply.) facts.
rules.
questions.
119. A fact starts with a relationship followed by a list of can have a struc-
arguments. The arguments of a fact ture similar to that
of a fact.
121. A higher order function is a function that takes the operator of a func-
tion as an argu-
ment.
22 / 22