Question 106

What happens when you attempt to compile and run the following code?
#include <iostream>
#include <string>
using namespace std;
class A {
public:
A() { cout << "A no parameters";}
A(string s) { cout << "A string parameter";}
A(A &a) { cout << "A object A parameter";}
};
class B : public A {
public:
B() { cout << "B no parameters";}
B(string s) { cout << "B string parameter";}
};
int main () {
A a2("Test");
B b1("Alan");
B b2(b1);
return 0;
}
  • Question 107

    What is the output of the program?
    #include <iostream>
    using namespace std;
    class BaseC
    {
    int i;
    public:
    BaseC() { i=?1;}
    BaseC(int i) { i=i; }
    void seti(int a) { i = a; };
    void Print() { cout << i; }
    };
    int main()
    {
    BaseC *o = new BaseC();
    o?>seti(10);
    o?>Print();
    }
  • Question 108

    What happens when you attempt to compile and run the following code?
    #include <iostream>
    using namespace std;
    int main(){
    int i, j;
    for(i = 0, j = 1; j < 2, i < 4; i++, j++);
    cout << i << " " << j;
    return 0;
    }
  • Question 109

    What will happen when you attempt to compile and run the following code?
    #include <iostream>
    using namespace std;
    int main()
    {
    const char *s;
    char str[] = "Hello ";
    s = str;
    while(*s) {
    cout << *++s;
    *s++;
    }
    return 0;
    }
  • Question 110

    How many times will "HELLO" be printed?
    #include <iostream>
    using namespace std;
    int main()
    {
    for(int i=?1; i<=10; i++)
    {
    if(i < 5)
    continue;
    else
    break;
    cout<<"HELLO";
    }
    return 0;
    }