Question

Multiple choice questions 1. A variable that is shared by all objects of a class is...

Multiple choice questions

1. A variable that is shared by all objects of a class is called_________?

A.Static variable

B. Const variable

C.Member variable

D. None of the above

2. Each object of a class has its own copy of the class's:

A. member functions

B. static member variables

C. instance member variables

D. A & C

E. A & B

3. In a vector, which of the following statements is true? (can have multiple answers)

a) Indexing vector access is range checked.

b) The range of legal index values for a vector is 0 to the value of v.size()-1

c) To add a value use the member function v.push_front( )

d) To manage size of reserve use v.reserve(newReserve)

e) To increase or decrease a vector’s size v.new_size(newSize);

4. Which statement is true about strings and c-string?

A. A string is a class and a c-string is created with an array

B. A c-string is a class and a string is created with an array

c. A c-string has a member function to get the size

d. A string is created with vectors and c-string is created with arrays

e. None of these

5. Which one of the following statements declares a c-string variable?

a.char c;

b. string s;

c. char c[10];

d.string s[10];

6. ________________ function returns the uppercase version of expression.

a. tolower(expression);

b. upper(expression)

c. toupper(expression);

d. isupper(expression);

7. Which of the following creates a string object with data ‘csci-1410’?

a. string str;

b. string ‘csci-1410’;

c. string s("csci-1410");

d. string s(csci-1410);

8. When a member function is defined (or implemented) outside of the class declaration, the function name must be qualified with the:

a.private access specifier

b.class name, followed by a single semicolon (:)

c.name of the first object

d.class name, followed by the scope resolution operator (::)

e.None of these

9.The value of a class type is called ________.

a.Regular variable

b.Object instance or object

c.Pointer variable

d.All of the above

e.None of the above

10.Which statement correctly defines a vector object for holding Dealer objects?

a.Dealer vector v;

b.Dealer<vector> v;

c.vector<Dealer> v;

d.vector v<Dealer>;

11.One of the following statements defines an array of strings having size SIZE.

a.string array;

b.string [SIZE]array;

c.string array[SIZE];

d.string *array;

12. One of the following statements dynamically allocates an array of floats having size SIZE.

a.float array;

b.float *array[SIZE];

c.float array = new float[SIZE];

d.float *array = new float[SIZE];

13. Which of the following statements declare two-dimensional array?

a.int a[];

b.int a[5][6];

c.int a[][];

d.int a[][4];

e.None of the above

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

Question 1) Answer Option A

Reason: Option A is correct because a static variable is a variable whose one copy is created and is used by all the class members. This variable will be shared among all the instance of the class.

Option B is incorrect because a constant variable is a variable whose value will not be shared once it is declared

Option C is incorrect because it is an instance variable or an object which is created with the new keyword.

Question 2) Answer Option C

Reason: Option A is incorrect because a member function is not a single copy of the class.

Option B is incorrect because a static member variable will remain same throughout the program.

Option C is correct because a member variable is an instance of the class which is a copy of its class.

Question 3) Answer Option B, C

Reason: Option A is incorrect because indexing vector access is not range checked.

Option B is correct because the range of the vector starts from 0 untill 1 less than the total range.

Option C is correct because v.push_front( ) is used to push a value in the front of a list.

Option D is incorrect because it is not used for managing the size of reserve.

Option E is incorrect because it is used to change the size of unordered list.

Option E is incorrect because

Add a comment
Know the answer?
Add Answer to:
Multiple choice questions 1. A variable that is shared by all objects of a class is...
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
  • Some pointer arithmetic is allowed. Which of the following arithmetic operators is allowed? (can have multiple...

    Some pointer arithmetic is allowed. Which of the following arithmetic operators is allowed? (can have multiple answers) a) pointer + integer b) pointer - pointer c) pointer - integer d) integer + pointer e) integer * pointer Which statement correctly defines a vector object for holding Dealer objects? a.Dealer vector v; b.Dealer<vector> v; c.vector<Dealer> v; d.vector v<Dealer>; One of the following statements dynamically allocates an array of floats having size SIZE. a.float array; b.float *array[SIZE]; c.float array = new float[SIZE];...

  • 5. Which one of the following statements declares a c-string variable? a.char c; b. string s;...

    5. Which one of the following statements declares a c-string variable? a.char c; b. string s; c. char c[10]; d.string s[10]; 6. ________________ function returns the uppercase version of expression. a. tolower(expression); b. upper(expression) c. toupper(expression); d. isupper(expression); 7. Which of the following creates a string object with data ‘csci-1410’? a. string str; b. string ‘csci-1410’; c. string s("csci-1410"); d. string s(csci-1410);

  • You will write the following files: mystack.h - contains the class definition for the mystack class....

    You will write the following files: mystack.h - contains the class definition for the mystack class. mystack.cpp - contains the definitions for member functions of the mystack class. inpost.cpp - contains your convert() function. inpost.h - contains the function prototype for convert() so that the main() can call it. Each of the files (with the exception of inpost.h) is described in more detail below. All header files should contain header guards to prevent them from being included multiple times in...

  • 1. What is the storage class of a class data member that is shared by all...

    1. What is the storage class of a class data member that is shared by all of the object instances of that class? 2. Is it possible for some of the elements of an array to be int and some of the elements in the same array to be double? 3. Is the following array definition valid?       char example[]={2, 14, 3, 4}; 4. Is the following a valid C++ statement?       var1 = sqrt(int v); 5. Do the following...

  • Part 1. (60 pts) 1. Define an Address class in the file Address.h and implement the...

    Part 1. (60 pts) 1. Define an Address class in the file Address.h and implement the Address class in Address.cpp. a. This class should have two private data members, m_city and m_state, that are strings for storing the city name and state abbreviation for some Address b. Define and implement public getter and setter member functions for each of the two data members above. Important: since these member functions deal with objects in this case strings), ensure that your setters...

  • Multiple Choice Multiple Choice Section 3.1 The Bag ADT For the bag class in Chapter 3...

    Multiple Choice Multiple Choice Section 3.1 The Bag ADT For the bag class in Chapter 3 (using a fixed array and a typedef statement) what steps were necessary for changing from a bag of integers to a bag of double values? A. Change the array declaration from int data[CAPACITY] to double data[CAPACITY] and recompile. B. Change the int to double in the typedef statement and recompile. C. Round each double value to an integer before putting it in the bag....

  • Multiple Choice Multiple Choice Section 4.1 Pointers and Dynamic Memory Consider the following statements: int *p;...

    Multiple Choice Multiple Choice Section 4.1 Pointers and Dynamic Memory Consider the following statements: int *p; int i; int k; i = 42; k = i; p = &i; After these statements, which of the following statements will change the value of i to 75? A. k = 75; B. *k = 75; C. p = 75; D. *p = 75; E. Two or more of the answers will change i to 75. Consider the following statements: int i =...

  • Antique Class Each Antique object being sold by a Merchant and will have the following attributes:...

    Antique Class Each Antique object being sold by a Merchant and will have the following attributes: name (string) price (float) And will have the following member functions: mutators (setName, setPrice) accessors (getName, getPrice) default constructor that sets name to "" (blank string) and price to 0 when a new Antique object is created a function toString that returns a string with the antique information in the following format <Antique.name>: $<price.2digits> Merchant Class A Merchant class will be able to hold...

  • Multiple Choice Multiple Choice Section 2.1 - 2.2 Introduction to Classes Here is the start of...

    Multiple Choice Multiple Choice Section 2.1 - 2.2 Introduction to Classes 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 alter the PRIVATE member variables of the foo object that activates the function? A. Only x can alter the private member variables of the object that activates the function. B. Only y can alter the private member variables...

  • members of a class non-friends, non-members of a class All of the above be 13. Why...

    members of a class non-friends, non-members of a class All of the above be 13. Why do you want to usually make data members private in a class? so that no one can use the class ensure data integrity b. provide data abstraction c provide information hiding. d. e. Band D B.C and D 14. The copy constructor for a class is called when an object of the class is passed by value to a function. when an object of...

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
ADVERTISEMENT