Question

1. Consider the accompanying class definition, and the declaration: ovalType smallOval; Which of the following statements...

1. Consider the accompanying class definition, and the declaration:

ovalType smallOval;

Which of the following statements is correct?

ovalType:print();

smallOval:print();

smallOval.print();

ovalType.print();


2. Which of the following statements correctly initializes the component length of mySquare?

mySquare(length)= 5;

mySquare[0]= 5;

mySquare.length = 5;

mySquare = {5};


3. Suppose that inventory is an array of 50 components of type int. Which of the following correctly initializes the array inventory?

for (int j = 1; j <= 50; j++)
inventory[j] = 0.0;

for (int j = 0; j <= 49; j++)
inventory[j] = 0;

for (int j == 1; j <= 49; j++)
inventory[j] = 0.0;

for (int j == 0; j <= 50; j++)
inventory[j] = 0;


4. Which of the following monitors the overall activity of the computer and provides services?

arithmetic logic unit

central processing unit

computer application

operating system

5. Which of the following is an example of a floating point data type?

char

double

int

short


6. Suppose that ch1 and ch2 are char variables and the input is:

ABCD

What is the value of ch2 after the following statements execute?

cin.get(ch1);
cin.putback(ch1);
cin >> ch2;

A

D

B

C


7. Which of the following statements correctly initializes the component length of mySquare?

mySquare = {5};

mySquare.length = 5;

mySquare[0]= 5;

mySquare(length)= 5;


8. What is the output of the following code?

enum courses {CALCULUS, FORTRAN, COBOL, RELIGION, HISTORY};
courses registered;
registered = FORTRAN;
cout << registered+1 << endl;

FORTRAN

1

2

COBOL


9. What does every node (except of the last node) in a singly linked list contain?

the address of the next node

no address information

the address of the previous node

the next node


10. In what type of recursive function is the last statement executed the recursive call?

indefinite recursive

direct recursive

indirect recursive

tail recursive


11. If the derived class classA overrides a public member function functionName of the base class classD, then to specify a call to that public member function of the base class you use the statement ____.

classD.functionName();

classA.functionName();

classA::functionName();

classD::functionName();


12. What is the return type of the function operator ==?

int

void

char

bool


13. If the search item is the 500th item in the list, how many key comparisons does the sequential search make to find the search item?

250

500

125

50


14. What is a variable or expression listed in a call to a function?

formal parameter

data type

type of the function

actual parameter


15. The following expression (a + b) * (c - d) is equivalent to which of the following postfix expressions?

a b - + c d *

a b c d - + *

a b + c d - *

c d + a b - *


16. What is the value of z after the following statements execute?

int z = 10;
int *p;
p = &z;
*p = 12;

0

12

null

10


17. Suppose that z is an int variable. Which of the following expressions always evaluates to true?

(z > 0) && ( z == 0)

(z > 0) || (z == 0)

(z >= 0) || ( z <= 0)

(z > 0) && (z >= 0)


18. To sort a list of length 500, bubble sort makes about how many item assignments?

"500,000"

"62,000"

"124,000"

"11,000"


19. Which of the following is a valid C++ statement?

assert(0 += divisor);

assert(divisor is 0);

assert(divisor == 0);

assert(divisor = 0);


20. What is the output of the following code?

stackType stack;
int x, y;

x = 9;
y = 3;
stack.push(8);
stack.push(x);
stack.push(x + 1);
y = stack.top();
stack.pop();
stack.push(x + y);
x = stack.top();
stack.pop();

cout << ""x = "" << x << endl;

x = 22

x = 19

x = 15

x = 12

0 0
Add a comment Improve this question Transcribed image text
Answer #1

1 smallOval.print();

2 mySquare.length = 5;

3 for (int j = 0; j <= 49; j++)
inventory[j] = 0;

4 operating system

5 double

6 A

7 mySquare.length = 5;

8COBOL

9the address of the next node

10tail recursive

Add a comment
Know the answer?
Add Answer to:
1. Consider the accompanying class definition, and the declaration: ovalType smallOval; Which of the following statements...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • JAVA Lab Create a class called ArrayBasedStack. Declare the following variables: • data: references an array...

    JAVA Lab Create a class called ArrayBasedStack. Declare the following variables: • data: references an array storing elements in the list • topOfStack: an int value representing the location of the stack top in the array • INITIAL_CAPACITY: the default capacity of the stack public class ArrayBasedStack <E> { private E[] data; private int topOfStack; private static final int INITIAL_CAPACITY = 5; } Add a constructor that will initialize the stack with a user-defined initial capacity. The top of the...

  • in c++ please explain with answer 6. Given the following template function definition, which of the...

    in c++ please explain with answer 6. Given the following template function definition, which of the following is not a valid invocation of the function? template <class T> a. swap(s1,s2); void swap(T& left, T& right) b. swap(int1, int2); { c. swap(ch1, ch2); //implementation d. swap(int1, ch2); } int int1, int2; float flt1, flt2; char ch1, ch2; string s1, s2; 7. Why can you not use the swap template function to swap two complete arrays? template <class T> void swap(T& left,...

  • ____     1.   Assume you have the following declaration char nameList[100];. Which of the following ranges is...

    ____     1.   Assume you have the following declaration char nameList[100];. Which of the following ranges is valid for the index of the array nameList? a. 0 through 99 c. 1 through 100 b. 0 through 100 d. 1 through 101 ____     2.   Assume you have the following declaration int beta[50];. Which of the following is a valid element of beta? a. beta['0'] c. beta[0] b. beta['1'] d. beta[50] ____     3.   Suppose that sales is an array of 50 components of...

  • 5) Consider the following Java statements, assuming that MyStack is a class that implements the interface...

    5) Consider the following Java statements, assuming that MyStack is a class that implements the interface StackInterface : int n = 4; StackInterface stack = new MyStack<>(); while (n > 0) { stack.push(n); n--; } // end while int result = 1; while (!stack.isEmpty()) { int integer = stack.pop(); result = result * integer; } // end while System.out.println("result = " + result); a.) What value is displayed when this code executes? b.) What mathematical function does the code evaluate?...

  • (a) Consider the following C++ function: 1 int g(int n) { 2 if (n == 0)...

    (a) Consider the following C++ function: 1 int g(int n) { 2 if (n == 0) return 0; 3 return (n-1 + g(n-1)); 4} (b) Consider the following C++ function: 1 bool Function (const vector <int >& a) { 2 for (int i = 0; i < a. size ()-1; i ++) { 3 for (int j = i +1; j < a. size (); j ++) { 4 if (a[i] == a[j]) return false; 5 6 } 7 return...

  • Introduction In this lab, you are supposed to implement a graph class with the data structure...

    Introduction In this lab, you are supposed to implement a graph class with the data structure implemented before like linked list and queue. graph The class graph contains three member variables: linkedList *adjacentVertices; //an array of linked list. For a vertice i, adjacentVertices[i] stores the linked list that contains all other vertices connected to vertice i. int numVertices; //The number of vertices in the graph. int maxNumVertices; //The maximum number of vertices the graph can hold. Following public methods are...

  • Consider the following class Point which represents a point in Cartesian coordinate system. The class has...

    Consider the following class Point which represents a point in Cartesian coordinate system. The class has two instance variables x and y which represent its position along the x-axis and y-axis. The constructor of the class initializes the x and y of the point with the specific value init; the method move() moves the point as specified by its parameter amount. Using the implementation of the class Point information and write its specification. The specification of the class includes the...

  • 1. What does the below C++ statement do? vector<double> myVec(20); Group of answer choices A.It creates...

    1. What does the below C++ statement do? vector<double> myVec(20); Group of answer choices A.It creates a vector object that can only store values of 10 or less. B.It creates a vector object with a starting size of 10. C.It creates a vector object and initializes the first element with the value 20. D.It creates a vector object with a starting size of 20. 2. A recursive function contains a call to itself, but is limited to 10 recursive calls...

  • 25. Given the array declaration double xyz [20]: which of the following statements are true? a....

    25. Given the array declaration double xyz [20]: which of the following statements are true? a. The array may hold up to 20 elements which may be accessed by the subscripts 0 through 20 b. The array may hold up to 21 elements which may be accessed by the subscripts 0 through 20 c. The array may hold up to 21 elements which may be accessed by the subscripts 0 through 19 d. The array may hold up to 20...

  • 1. (TCO 1) What is the output of the following C++ code? int list[5] = {0,...

    1. (TCO 1) What is the output of the following C++ code? int list[5] = {0, 5, 10, 15, 20}; int j; for (j = 0; j < 5; j++)      cout << list[j]; (Points : 4)         0 1 2 3 4         0 5 10 15         0 5 10 15 20         5 10 15 20 Question 2.2. (TCO 1) What is stored in alpha after the following code executes? int alpha[5] = {0}; int j; for (j = 0; j...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT