Question
1)Which statement is correct about adding a node to a linked list? A)You cannot add a new node in a linked list after the linked
1)Which statement is correct about adding a node to a linked list?
A)You cannot add a new node in a linked list after the linked list is created.
B)You can add a node anywhere in a linked list.
C)You can add a node only at the beginning of a linked list.
D)You can add a node only at the end of a linked list.
2)How can you locate the fifth node in a doubly-linked list named invoices?
A)invoices[5]
B)invoices[4]
C)Start at the first node and follow pointers to the next node in the list until the fifth node is located.
D)None of the listed options.
3)What is the problem with the following code snippet, which is attempting to locate the first element in the list names?
list
...
string first = names[1];
A)The first element will be located by using names[0].
B)It is not legal to use the [] operator with a list
C)You need to first check that the size of names is at least 2.
D)There is no problem with the code snippet.
4)Consider the following code snippet:
int numarray[6];
for (int cnt = 1; cnt < 6; cnt++)
{
numarray[cnt] = cnt + 1;
}
Which one of the following statements is correct about the given code snippet?
a) The for loop initializes all the elements of the array.
b) The for loop initializes all the elements except the first element.
c) The for loop initializes all the elements except the last element.
d) The for loop initializes all the elements except the first and last elements.
5)Based on the following code snippet, which of the following function calls are legal? Assume that car is a Car object and aero is an AeroCar object.
class Car
Car();
void set_speed(double new_speed);
double get_speed() const;
void display() const;
double speed;
class AeroCar : public Car
AeroCar();
void set_speed(double new_speed);
void set_height(double new_height);
double get_height() const;
double height;
A)car.get_height() and aero.get_height()
B)car.get_speed() and aero.get_speed()
C)Both a and b
D)Neither a nor b
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started