Exercise: Python

Questions for: Functions

Which of the following statement is correct about the program given below?
#include<iostream.h> 
static double gDouble; 
static float  gFloat; 
static double gChar; 
static double gSum = 0; 
class BaseOne
{
    public:
    void Display(double x = 0.0, float y = 0.0, char z = 'A')
    {
        gDouble = x;
        gFloat  = y;
        gChar   = int(z);
        gSum    = gDouble + gFloat + gChar;
        cout << gSum; 
    }
};
class BaseTwo
{
    public: 
    void Display(int x = 1, float y = 0.0, char z = 'A')
    {
        gDouble = x;
        gFloat  = y;
        gChar   = int(z); 
        gSum    = gDouble + gFloat + gChar;
        cout << gSum;
    }
};
class Derived : public BaseOne, BaseTwo
{
    void Show()
    {
        cout << gSum;
    } 
}; 
int main()
{
    Derived objDev;
    objDev.BaseTwo::Display(10, 20, 'Z');
    return 0; 
}
A:
The program will print the output 0.
B:
The program will print the output 120.
C:
The program will report run-time error.
D:
The program will report compile-time error.
Answer: D
No answer description is available. Let's discuss.
Which of the following statement is correct about the program given below?
#include<iostream.h> 
class ExamAdept
{
    int x; 
    float y; 
    public:
    void BixFunction(int = 0, float = 0.00f, char = 'A');
    void BixFunction(float, int = 10.00, char = 'Z');
    void BixFunction(char, char, char);
};
int main()
{
    ExamAdept objBix;
    objBix.BixFunction(10 * 1.0, int(56.0)); 
    return 0;
}
void ExamAdept::BixFunction(int xx, float yy, char zz)
{
    x = xx + int(yy);
    cout<< "x = " << x << endl;
}
void ExamAdept::BixFunction(float xx, int yy, char zz)
{
    x = zz + zz;
    y = xx + yy;
    cout<< " x = " << x << endl;
}
void ExamAdept::BixFunction(char xx, char yy, char zz)
{
    x = xx + yy + zz; 
    y = float(xx * 2); 
    cout<< " x = " << x << endl;
}
A:
The program will print the output x = 65.
B:
The program will print the output x = 66.
C:
The program will print the output x = 130.
D:
The program will print the output x = 180.
Answer: D
No answer description is available. Let's discuss.
Which of the following statement is correct about the program given below?
#include<iostream.h> 
static int Result;
class India
{
    public:
    void Change(int x = 10, int y = 20, int z = 30)
    {
        cout<< x + y + z;
    }
    void Display(int x = 40, float y = 50.00)
    {
        Result = x % x; 
        cout<< Result;
    }
};
class Bix
{
    int x, y; 
    public:
    void Change(int x, int y = 50)
    {
        cout<< x + y;
    }
};
class ExamAdept: public India, public Bix
{
    public:
    void Display(int x = 10, int xx = 100, int xxx = 1000)
    {
        Result = x + xx % x * x;
        cout<< Result ; 
    }
};
int main()
{
    ExamAdept objBix;
    objBix.India::Display(10, 20.00);
    return 0; 
}
A:
The program will print the output 0.
B:
The program will print the output 10.
C:
The program will print the output 30.
D:
The program will print the output 40.
Answer: A
No answer description is available. Let's discuss.
What is correct about the following program?
#include<iostream.h> 
class Base
{
    int x, y, z; 
    public: 
    Base()
    {
        x = y = z = 0;
    }
    Base(int xx, int yy = 'A', int zz = 'B')
    {
        x = xx;
        y = x + yy;
        z = x + y;
    }
    void Display(void)
    {
        cout<< x << " " << y << " " << z << endl;
    }
};
class Derived : public Base
{
    int x, y; 
    public:
    Derived(int xx = 65, int yy = 66) : Base(xx, yy)
    {
        y = xx; 
        x = yy;
    }
    void Display(void)
    {
        cout<< x << " " << y << " ";
        Display(); 
    }
};
int main()
{
    Derived objD;
    objD.Display();
    return 0; 
}
A:
The program will report compilation error.
B:
The program will run successfully giving the output 66 65.
C:
The program will run successfully giving the output 65 66.
D:
The program will run successfully giving the output 66 65 65 131 196.
Answer: E
No answer description is available. Let's discuss.
What will be the output of the following program?
#include<iostream.h> 
class Base
{
    int x, y; 
    public:
    Base() 
    {
        x = y = 0; 
    } 
    Base(int xx)
    {
        x = xx;
    }
    Base(int p, int q = 10)
    {
        x = p + q;
        y = q; 
    } 
    void Display(void)
    {
        cout<< x << " " << y << endl;
    } 
}objDefault(1, 1);

class Derived: public Base
{
    Base obj; 
    public:
    Derived(int xx, int yy): Base(xx, xx + 1)
    { }
    Derived(Base objB = objDefault)
    { } 
}; 
int main()
{
    Derived objD(5, 3);
    Derived *ptrD = new Derived(objD);
    ptrD->Display();
    delete ptrD;
    return 0; 
}
A:
3 2
B:
8 3
C:
11 6
D:
11 10
Answer: C
No answer description is available. Let's discuss.
Ad Slot (Above Pagination)
Quiz