Question 91

Which code, inserted at line 10, generates the output "2?1"?
#include <iostream>
#include <string>
using namespace std;
class A {
protected:
int y;
public:
int z;
};
//insert code here
public:
void set() {
y = 2;
z = 3;
}
void Print() { cout << y << z; }
};
int main () {
B b;
b.set();
b.z = ?1;
b.Print();
return 0;
}
  • Question 92

    Which code, inserted at line 18, generates the output "AB"
    #include <iostream>
    using namespace std;
    class A
    {
    public:
    void Print(){ cout<< "A";}
    void Print2(){ cout<< "a";}
    };
    class B:public A
    {
    public:
    void Print(){ cout<< "B";}
    void Print2(){ cout<< "b";}
    };
    int main()
    {
    B ob2;
    //insert code here ob2.Print(); }
  • Question 93

    What happens when you attempt to compile and run the following code?
    #include <iostream>
    using namespace std;
    int op(int x, int y);
    int main()
    {
    float *pf;
    float f=0.9;
    pf=&f;
    cout << op(1, *pf);
    return 0;
    }
    int op(int x, int y)
    {
    return x*y;
    }
  • Question 94

    Which code, inserted at line 5, generates the output "ABC"?
    #include <iostream>
    using namespace std;
    class A {
    public:
    //insert code here
    };
    class B:public A {
    public:
    void Print(){ cout<< "B"; }
    };
    class C:public B {
    public:
    void Print(){ cout<< "C"; }
    };
    int main()
    {
    A ob1;
    B ob2;
    C ob3;
    A *obj;
    obj = &ob1;
    obj?>Print();
    obj = &ob2;
    obj?>Print();
    obj = &ob3;
    obj?>Print();
    }
  • Question 95

    What happens when you attempt to compile and run the following code?
    #include <iostream>
    using namespace std;
    int x=5;
    static int y;
    int i=0;
    void static myFunction()
    {
    y=x++ + ++i;
    }
    int main (int argc, const char * argv[])
    {
    x++;
    myFunction();
    cout<<y<<" "<<x<< " " << i;
    }