cWelcome to Virtually helps.
www.vuhelp.com
Here is the start of a class declaration:
class Foo
{
public:
void x(Foo f);
void y(const Foo f);
void z(Foo f) const;
...
Which of the three member functions can change the PRIVATE member variables of the Foo
object that activates the function?
a. Only x and y
b. Only x and z
c. Only y and z
d. None of three the functions.
e. All three functions.
Question No: 2 Marks: 2
What is the common pattern of writing class definitions?
a. Member functions and member variables are both private.
b. Member functions are private, and member variables are public.
c. Member functions are public, and member variables are private.
d. Member functions and member variables are both public.
Question No: 3 Marks: 2
The Bag ADT is like the List ADT. The Bag ADT does not store items in any particular
order and it allows duplicates. Suppose that the Bag class is efficiently implemented with a fixed array
with a capacity of 4000. Insert appends the new item at the end of the array. Choose the best
description of b’s member variables size (count of items in the bag) and data (the array that holds
the actual items) after we execute these statements:
Bag b;
b.insert(5);
b.insert(4);
b.insert(6);
What will be the values of b.size and b.data after the statements?
a. b.size is 3, b.data[0] is 4, b.data[1] is 5, b.data[2] is 6
b. b.size is 3, b.data[0] is 5, b.data[1] is 4, b.data[2] is 6
c. b.size is 3, b.data[0] is 6, b.data[1] is 4, b.data[2] is 5
d. b.size is 3, b.data[0] is 6, b.data[1] is 5, b.data[2] is 4
Question No: 4 Marks: 2
The operation for adding an entry to a stack is traditionally called:
a. add
b. append
c. insert
d. push
Question No: 5 Marks: 5
Consider the following pseudo code:
declare a stack of characters
while ( there are more characters in
the word to read ) {
read a character
push the character on the stack
}
while ( the stack is not empty ) {
pop a character off the stack
write the character to the screen
}
What is written to the screen for the input “carpets”?
a. serc
b. carpets
c. steprac
d. ccaarrppeettss
Question No: 6 Marks: 2
In the linked list implementation of the stack class, where does the push member function
place the new entry on the linked list?
a. At the head
b. At the tail
c. After all other entries that are greater than the new entry.
d. After all other entries that are smaller than the new entry.
Question No: 7 Marks: 2
One difference between a queue and a stack is:
a. Queues require dynamic memory, but stacks do not.
b. Stacks require dynamic memory, but queues do not.
c. Queues use two ends of the structure; stacks use only one.
d. Stacks use two ends of the structure, queues use only one.
Question No: 8 Marks: 2
I have implemented the queue with a linked list, keeping track of a front pointer and a rear
pointer. Which of these pointers will change during an insertion into a NONEMPTY queue?
a. Neither changes
b. Only front pointer changes.
c. Only rear pointer changes.
d. Both change.
Question No: 9 Marks: 2
I have implemented the queue with a linked list, keeping track of a front pointer and a rear
pointer. Which of these pointers will change during an insertion into an EMPTY queue?
a. Neither changes
b. Only front pointer changes.
c. Only rear pointer changes.
d. Both change.
Question No: 10 Marks: 2
In a single function declaration, what is the maximum number of statements that may be
recursive calls?
a. 1
b. 2
c. n (where n is the argument)
d. There is no fixed maximum
Question No: 11 Marks: 2
What is the maximum depth of recursive calls a function may make?
a. 1
b. 2
c. n (where n is the argument)
d. There is no fixed maximum
Question No: 12 Marks: 2
In which location do dynamic variables reside?
a. The code segment.
b. The data segment.
c. The heap.
d. The run-time stack
Contact vuhelps@gmail.com
Regards
Vuhelps
No comments:
Post a Comment