C Multiple Choice QA 1 As a user caller of a function you re

C++ Multiple Choice Q&A

1. As a user (caller) of a function, you really don\'t need to know all of the details as to how the function computes its answer.

True or False?

2. To use a function, you only need to know its name, what to pass as input and what to expect as output.

True or False?

3. As the supplier of the function, you have to implement it fully and understand all of its inner workings.

True or False?

4. For a function declared as:

double foo( int x );
the parameter x is called an \"actual parameter\".

True or False?

5. For a function declared as:

double foo( int x );
the runtime value sent to the function for the value of x will sent \"by-value\".

True or False?

6. For a function declared as:

double foo( int x );
the return value will be of type int.

True or False?

7. For a function declared as:

double foo( int x );
it call be invoked without any compile errors or warnings by saying:
foo( 12 );

True or False?

8. For a function declared as:

double foo( int x );
it call be invoked without any compile errors or warnings by saying:
foo( i + 1 );
for a declared and initialized int variable named i.

True or False?

9.The C++ statement:

#include
is a preprocessor command.

True or False?

10. The C++ statement:

#include
performs \"textual substitution\".

True or False?

11. The standard math functions like sqrt(...), floor(...) and fabs(...) come from the library .

True or False?

12. A function defined to return void is what other programming languages call a \"subroutine\".

True or False?

13. If a function is defined to return void, it does not need to have an ending return; statement before the closing brace that ends the function.

True or False?

14. ++ is the decrement operator in C++.

True or False?

15. If the function foo wants to have its parameter x passed by reference, it should be declared as:

double foo( int x );

True or False?

16. In C++, if a programmer wants to call a function foo that accepts a single run-time parameter x passed by reference, the programmer should say:

foo( &a );
for some declared variable a.

True or False?

17. Parameters passed by reference in C++ must be l-values, not r-values.

True or False?

18. Parameters passed by value in C++ must be l-values, not r-values.

True or False?

19. A class typically represents a \"thing\".

True or False?

20. The methods of a class represents the \"actions\" that thing knows how to perform.

True or False?

21. The member variables of a class represent the data values associated with that thing.

True or False?

22. A constructor always gets called when a class is asked to create an object.

True or False?

23. Given an object o, C++ programmers use the operator -> to reference the members and methods of that object.

True or False?

24. Typically, most objects have their member variables marked public.

True or False?

25. Typically, most objects have their methods marked private.

True or False?

26. cout is an example of a class.

True or False?

27. cin is an example of a method.

True or False?

28. When implemented in CS 52, a class will be constructed from two files.

True or False?

29. Any pile of code that wants to use your class must #include your class\' header (.h) file.

True or False?

30. In C++, the textual symbols used to separate variables in an expression (like +, -, / or *) are referred to as \"operators\".

True or False?

In this course, we will be marking all of our operators as friend functions.

Although there are exceptions to this rule, C++ programmers have the power to decide what two parameters their operators take and what type they return.

The following code:
Student s; Customer c;
Grapefruit g = s + c;
calls the operator+ defined as:
Grapefruit operator+ ( Customer c, Student s );.

The following code:
Grapefruit g;
cout << g;
calls the operator<< defined as:
friend ostream& operator<<( ostream& outs, const Grapefruit & g );.

In C++, operator+ comes in two overloaded forms, one that takes one argument and one that takes two arguments.

In C++, operator- comes in two overloaded forms, one that takes one argument and one that takes two arguments.

In C++, operator<< comes in two overloaded forms, one that takes one argument and one that takes two arguments.

In C++, operator>> comes in two overloaded forms, one that takes one argument and one that takes two arguments.

In the declaration:
   int myArray[ 10 ];
is a valid array declaration in C++.

In the declaration:
   int i = 10;
   int myArray[ i ];
is a valid array declaration in C++.

In the declaration:
   int myArray[ 10 ];
a total of 10 integer values will make up the array named myArray.

C++ allows arrays of classtype for any class defined in C++.

The following code:
Student myStudents[ 10 ];
will call the parameterless constructor on each of the 10 spots defined in the array.

When declaring an array of classtype such as:
Student myStudents[ 10 ];
there is no way for a programmer to tell C++ which constructor to use to initialize the elements of the array.

Recursive functions are ones which may call themselves over and over again.

When a recursive function hits its base case, it returns an actual value without calling itself anymore to determine the answer.

Every recursive function needs one (or more) base cases as well as one (or more) recursive cases.

When a recursive function never reaches its base case, C++ will return the value 0 when the function finishes running.

In C++, the following code:
string s = \"Hello\";
for (int i = 0; i < s.length(); i++)
     cout << s.at( i ) << endl;
will print out each letter of the variable s on a different line all by itself.

Whether you are working with char * or string objects, there is a getline(...) function that enables you to read a whole line of data, including the whitespace.

An exception is an alternative way of returning from a function or class method that designates that some failure occurred.

In the declaration:
   std::logic_error le( \"message\" );
le is the name of an object of type logic_error.

In this course, typically, class methods throw exceptions that driver code will catch.

In C++, the class string is part of the namespace std and requires that programmers #include .

When reading text, the standard >> operator will break on whitespace and eats leading whitespace.

In C++, the declaration:
char * myString = \"Hello\";
produces an object with many different available methods we can call.

In C++, the following code:
char * myString = \"Hello\";
char * otherString = \"Hello\";
if (myString == otherString)
{
cout << \"Strings are equal\" ;
}
is a legal and valid way to test that the two strings have the same value.

Any pointer variable you declare and new, you must delete when you are finished using it.

In the declaration:
   int* myArray = new int[ 10 ];
myArray is the name of an array of int declared to hold 10 elements.

In the declarations:
   int i = 10;
   int* myArray = new int[ i ];
myArray is the name of an array of int declared to hold 10 elements.

With the declarations:
   int i = 10;
   int* myArray = new int[ i ];
the correct way to delete the variable myArray is to say:
   delete( myArray );

With the declaration:
   int* pInt = new int( 10 );
the correct way to delete the variable pInt  is to say:
   delete [] pInt;

With the declarations:
int i = 10;
int* pInt = &i;
programmers must not delete pInt when they are finished using it.

With the declarations:
int i = 10;
int* pInt = &i;
the following statement will set the value of the variable i to 11:
*pInt = 11;

When a programmer writes the statements:
int* pInt = new int( 10 );
int* pAnotherInt = new int( 11 );
pAnotherInt = pInt;
the programmer has created a \"memory leak\".

With the declarations:
Customer c;
Customer* pCustomer = &c;
the following statement will invoke the setName method on the object c:
pCustomer->setName( \"Howard\" );

The -> operator can only be used on pointer variables that are do not have the value NULL or nullptr.

A pointer to any type can be set to NULL or nullptr.

Inheritance is a way that programmers can implement a \"HAS-A\" or \"part-of\" relationship.

In the declaration:
   class Foo : public Bar
Bar is the subclass of the class Foo.

When defining inheritance in C++, in addition to defining a .h file correctly, programmers must also correctly code constructor calls so that they call their parent class constructors.

In C++, not every class has a parent class it inherits from.

With the declaration:
   class Foo : public Bar
and the objects:
   Foo f;   Bar b;
it is always safe to say:
   b = f;

With the declaration:
   class Foo : public Bar
and the objects:
   Foo f;   Bar b;
it is always safe to say:
   f = b;

With the declaration:
   class Foo : public Bar
every instance of a Foo is an special kind of Bar.

When working with inheritance and virtual functions, the keyword virtual only belongs in a .cpp file.

Once a method is marked virtual in a parent class, every subclass has that virtualmethod, whether they say it not.

Only methods can be marked virtual, not class data members.

Typically, class constructors are overloaded to provide many convenient ways to create an object.

A class can declare an enumeration in its public or private area.

The access modifiers public and private can be listed many times within a class\' header (.h) file.

Left unstated, the default access modifier of a class in C++ is private.

Default-valued parameter arguments do not need to be passed when invoking the function or class method that defines their value.

C++ uses a this pointer value at runtime to track which object is being used when a class\' method is called.

Both Visual Studio and XCode shows the features of a class thru many distinctive icons.

The enumerated value YELLOW shown below:
enum COLOR { BLUE = 2, RED, YELLOW } ;
will have the value 4.

True

Solution

1. True
2. True
3. True
4. False
5. True
6. False
7. True
8. True
9. True
10. True
11. True
12.
13. True
14. False
15. False
16. True
17. True
18. False
19. True
20. True
21. True
22. True
23. False
24. False
25. False
26. False
27. False
28.
29. True
30. True


Note:
please share remaining as different thread

C++ Multiple Choice Q&A 1. As a user (caller) of a function, you really don\'t need to know all of the details as to how the function computes its answer. T
C++ Multiple Choice Q&A 1. As a user (caller) of a function, you really don\'t need to know all of the details as to how the function computes its answer. T
C++ Multiple Choice Q&A 1. As a user (caller) of a function, you really don\'t need to know all of the details as to how the function computes its answer. T
C++ Multiple Choice Q&A 1. As a user (caller) of a function, you really don\'t need to know all of the details as to how the function computes its answer. T
C++ Multiple Choice Q&A 1. As a user (caller) of a function, you really don\'t need to know all of the details as to how the function computes its answer. T
C++ Multiple Choice Q&A 1. As a user (caller) of a function, you really don\'t need to know all of the details as to how the function computes its answer. T
C++ Multiple Choice Q&A 1. As a user (caller) of a function, you really don\'t need to know all of the details as to how the function computes its answer. T

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site