Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

1)Which statement is incorrect? A)Any use of the keyword const is a promise to t

ID: 3869436 • Letter: 1

Question

1)Which statement is incorrect?

A)Any use of the keyword const is a promise to the compiler, and a request to the compiler to enforce the promise

B)The functions or data members declared in the private: section of a class can be accessed only in the definition of those functions declared in that class

C)A class may not have another class type object as a member.

D)The keyword static is used in a static function declaration in a class but not in the function definition

2)Which statement is incorrect?

A)If we use an out of range index with an array, there will NOT be an error message from the compiler.

B)A static variable of a class can be changed.

C)If we use an out of range index with a vector, there will NOT be an error message from the compiler.

D)Inline functions are always more efficient than noninline functions

3)Which of the following is NOT a legal access to the class or struct members? Assume each is outside of the class member definitions,

struct S          class C          class D

{                 {                {

int x;            int x;         public:

  int y;            int y;           int x;

}                 private:           int y;

S s;                int z;         private:

                  };                 int z;

                 C c;             };

                                   D d;

A)d.x

B)s.x

C)d.y

D)c.x

4)Consider the class inheritance.

class B{

public:

B();

B(int nn);

void f();

void g();

private:

int n;

};

class D: public B

{

public:

D(int nn, float dd);

  void h();

private:

double d;

};

How many private members does an object of class D have?

A)4

B)1

C)2

D)0

5)Which statement is incorrect?

A)If class D is derived from class B, then we say that class D inherits from class B.

B)If class D is derived from class B, we speak of D as the child class and B as the parent class.

C)If class D is derived from class B, we speak of D as the derived class and B as the base class.

D)If class D is derived from class B then class D has only some of the members from B, and the additional members defined in D.

6)A derived class object inherits all the members of the base class. Which of these remarks about the inherited member variables is incorrect?

A)Inherited members are need to be allocated memory and should be initialized at creation of a derived class object.

B)Inherited members’ memory allocation must be done by the base class constructor for the base class, which must be called.

C)Inherited members are not accessible to the derived class functions so can safely be ignored

D)The base class constructor is the most convenient place to initialize these inherited variables.

7)Which method is NOT used to find th root of an equation?

A)Bisection

B)Regula falsi

C)Trapezoidal rule

D)Secant

8)How many integration methods were explained in class?

A)4

B)2

C)1

D)3

9)Which numerical method was implemented in class?

A)Trapezoidal rule

B)Secant

C)Regula falsi

D)Simpson rule

10)What is required in order to find the root of a function by numerical methods?

A)The function value at the start of the interval and the function value at the end of the interval must be of opposite signs

B)The function value at the start of the interval and the function value at the end of the interval must be of the same sign

C)The number of iterations must be very large

D)The epsilon value must be very small

Explanation / Answer

Solution:

1)

B statement is incorrect, because irrespective of the definition of the function where the function is called from is also matters.

2)

C)

Unlike arrays in c++, vector gives an error when index is out of bound.


3)

D) c.x, because by default in c++, the visibility of data member is private, that is why it is illegal.


5)

D) The derived class or child class will always have all the members from parent class.


7)

C, Rest of the methods are used for finding the root.

I hope this helps, if you find any problem. Please comment below. Don't forget to give a thumbs up if you liked it. :)