Question: QUESTION 1 Given the following class class car : public fourWheels { ... } which of the following statements is true? car is derived class

QUESTION 1

  1. Given the following class
  2. class car : public fourWheels {
  3. ...
  4. }
  5. which of the following statements is true?
  6. car is derived class and fourWheels is a base class
  7. fourWheels is derived class and car is a base class
  8. both fourWheels and car are base classes
  9. both fourWheels and car are derived classes

10 points

QUESTION 2

  1. Given the following classes
  2. class testA {
  3. int d;
  4. public:
  5. int a;
  6. protected:
  7. int b;
  8. private:
  9. int c;
  10. }
  11. class testB:testA{
  12. public:
  13. void display(){
  14. ..............
  15. }
  16. }
  17. which of the following lines can be placed inside display() function
  18. cout << d;
  19. cout << c;
  20. cout << b;
  21. cout << a << d;

10 points

QUESTION 3

  1. Given the following code
  2. class testA {
  3. int d;
  4. public:
  5. int a;
  6. protected:
  7. int b;
  8. private:
  9. int c;
  10. }
  11. class testB:testA{
  12. .........
  13. }
  14. int main(){
  15. testA x;
  16. testB y;
  17. .........
  18. }
  19. which of the following lines can be placed inside the main() function
  20. x.c=1;
  21. y.a=1;
  22. y.c=1;
  23. x.b=1;

10 points

QUESTION 4

  1. Given the following code:
  2. class testA {
  3. public:
  4. set(int a);
  5. }
  6. class testB:testA{
  7. public:
  8. set(int b);
  9. }
  10. The use of the same function name "set" in the derived class as in the base class is called
  11. constructor overloading
  12. constructor passing
  13. Shadowing
  14. composition

10 points

QUESTION 5

  1. Given the following code:
  2. class testA {
  3. public:
  4. testA(int a);
  5. }
  6. class testB:testA{
  7. public:
  8. testB(int b, int c);
  9. }
  10. which constructor definition that can be used in testB that passes argument to the base class constructor?
  11. testB(int b, int c)=>(c){....}
  12. testB(int b, int c):testB(b){....}
  13. testA(int b, int c):testB(c){....}
  14. testB(int b, int c):testA(c){....}

10 points

QUESTION 6

  1. Which is the correct execution order for class destructors?
  2. both starts at the same time
  3. only the destructor of the deived class is executed
  4. Derived class then base class
  5. Base class then derived class

10 points

QUESTION 7

  1. When the Inheritance is represented in a diagram, what is the direction of the line between the derived and the base class?
  2. Bidirectional arrow between the derived to the base class
  3. The arrow from the derived to the base class
  4. No arrows line between the derived and the base class
  5. The arrow from the base to the derived class

10 points

QUESTION 8

  1. Given the following class
  2. class testA{
  3. int x,y;
  4. float b;
  5. intn[10];
  6. public:
  7. testA();
  8. };
  9. and this is the constructor definition:
  10. testA::testA(){
  11. x=0;
  12. y=1;
  13. b=1.1f;
  14. for(int i=0;i<10;i++) n[i]=i;
  15. }
  16. Write the code for declaration and for the definition/implementation for each of the following:
  17. - Copy constructor that perform the following:
  18. copy the values of x,y and b from the source object, and set the array n to zeros.
  19. - Copy assignment operator that perform the following:
  20. copy the values of x,y and b from the source object, and set the array n to -1;

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!