Answered step by step
Verified Expert Solution
Question
1 Approved Answer
QUESTION 1 Given the following class class car : public fourWheels { ... } which of the following statements is true? car is derived class
QUESTION 1
- Given the following class
- class car : public fourWheels {
- ...
- }
- which of the following statements is true?
- car is derived class and fourWheels is a base class
- fourWheels is derived class and car is a base class
- both fourWheels and car are base classes
- both fourWheels and car are derived classes
10 points
QUESTION 2
- Given the following classes
- class testA {
- int d;
- public:
- int a;
- protected:
- int b;
- private:
- int c;
- }
- class testB:testA{
- public:
- void display(){
- ..............
- }
- }
- which of the following lines can be placed inside display() function
- cout << d;
- cout << c;
- cout << b;
- cout << a << d;
10 points
QUESTION 3
- Given the following code
- class testA {
- int d;
- public:
- int a;
- protected:
- int b;
- private:
- int c;
- }
- class testB:testA{
- .........
- }
- int main(){
- testA x;
- testB y;
- .........
- }
- which of the following lines can be placed inside the main() function
- x.c=1;
- y.a=1;
- y.c=1;
- x.b=1;
10 points
QUESTION 4
- Given the following code:
- class testA {
- public:
- set(int a);
- }
- class testB:testA{
- public:
- set(int b);
- }
- The use of the same function name "set" in the derived class as in the base class is called
- constructor overloading
- constructor passing
- Shadowing
- composition
10 points
QUESTION 5
- Given the following code:
- class testA {
- public:
- testA(int a);
- }
- class testB:testA{
- public:
- testB(int b, int c);
- }
- which constructor definition that can be used in testB that passes argument to the base class constructor?
- testB(int b, int c)=>(c){....}
- testB(int b, int c):testB(b){....}
- testA(int b, int c):testB(c){....}
- testB(int b, int c):testA(c){....}
10 points
QUESTION 6
- Which is the correct execution order for class destructors?
- both starts at the same time
- only the destructor of the deived class is executed
- Derived class then base class
- Base class then derived class
10 points
QUESTION 7
- When the Inheritance is represented in a diagram, what is the direction of the line between the derived and the base class?
- Bidirectional arrow between the derived to the base class
- The arrow from the derived to the base class
- No arrows line between the derived and the base class
- The arrow from the base to the derived class
10 points
QUESTION 8
- Given the following class
- class testA{
- int x,y;
- float b;
- intn[10];
- public:
- testA();
- };
- and this is the constructor definition:
- testA::testA(){
- x=0;
- y=1;
- b=1.1f;
- for(int i=0;i<10;i++) n[i]=i;
- }
- Write the code for declaration and for the definition/implementation for each of the following:
- - Copy constructor that perform the following:
- copy the values of x,y and b from the source object, and set the array n to zeros.
- - Copy assignment operator that perform the following:
- 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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started