Programs

Question 1 :

What will be the output of the following program?

#include < iostream . h > 
class IndiaParinam
{
    int x; 
    public:
    IndiaParinam(int xx, float yy)
    {
        cout<< char(yy);
    } 
}; 
int main()
{
    IndiaParinam *p = new IndiaParinam(35, 99.50f);
    return 0; 
}


A). 99
B). ASCII value of 99
C). Garbage value
D). 99.50
Answer : Option B

Question 2 :

Which of the following statement is correct about the program given below?

#include < iostream . h > 
class IndiaParinam
{
    public:
    IndiaParinam()
    {
        cout<< "India";
    }
    ~IndiaParinam()
    {
        cout<< "Parinam";
    }
};
int main()
{
    IndiaParinam objParinam;
    return 0; 
}


A). The program will print the output India.
B). The program will print the output Parinam.
C). The program will print the output IndiaParinam.
D). The program will report compile time error.
Answer : Option C

Question 3 :

Which of the following statement is correct about the program given below?

#include < iostream . h > 
class Parinam
{
      int x; 
    public:
      Parinam();
     ~Parinam();
      void Show() const;
};
Parinam::Parinam()
{
    x = 25;
}
void Parinam::Show() const
{
    cout<< x;
}
int main()
{
    Parinam objB;
    objB.Show();
    return 0; 
}


A). The program will print the output 25.
B). The program will print the output Garbage-value.
C). The program will report compile time error.
D). The program will report runtime error.
Answer : Option C

Question 4 :

Which of the following statement is correct about the program given below?

#include < iostream . h > 
class Parinam
{
      int x; 
    public:
      Parinam();
      void Show() const;
      ~Parinam(){}
};
Parinam::Parinam()
{
    x = 5;
}
void Parinam::Show() const
{
    cout<< x;
}
int main()
{
    Parinam objB;
    objB.Show();
    return 0; 
}


A). The program will print the output 5.
B). The program will print the output Garbage-value.
C). The program will report compile time error.
D). The program will report runtime error.
Answer : Option A

Question 5 :

What will be the output of the following program?

#include < iostream . h > 
int val = 0; 
class IndiaParinam
{
    public: 
    IndiaParinam()
    {
        cout<< ++val;
    }
    ~IndiaParinam()
    {
        cout<< val--; 
    } 
}; 
int main()
{
    IndiaParinam objParinam1, objParinam2, objParinam3;
    {
        IndiaParinam objParinam4;
    } 
    return 0;
}


A). 1234
B). 4321
C). 12344321
D). 12341234
E). 43211234
Answer : Option C