C++ Programming
Description: This test focuses on fundamental & programming skill concepts in C++ programming | |
Number of Questions: 15 | |
Created by: Sara Dalvi | |
Tags: Cpp Programming in C and C++ Java/Oracle /C/C++ |
What is the output of C++ program given below?
#include<iostream> using namespace std; int main() { typedef int hello; hello i=9.9; cout<<i; }
What is the output of C++ program given below?
#include<iostream> using namespace std; int main() { int y=8,x=6; (x=5)&&(x=7) ? y=1:y=2; cout<<x<<"_"<<y; }
Note: _ (underscore is used in cout statement to differentiate x & y value.
Which of the following statements is false regarding to namespace in C++ programming?
What is the output of C++ program given below?
#include<iostream> using namespace std; int main() { int i,j,k=5; for(i=1;i<=5;i++) { for(j=1;j<=k;j++) { cout<<j; } k=k-1; cout<<"n"; } }
What is the output of C++ program given below?
#include<iostream> using namespace std; class Test { public: Test() { cout<<"constructor of Testn"; } ~Test() { cout<<"destructor of Testn"; } }; int main() { Test a; Test b; }
What is the output of C++ program given below?
#include<iostream>
using namespace std;
class A
{
public:
A()
{
cout<<"Constructor of A"<<endl;
}
void Test();
};
void A::Test()
{
cout<<"This is Test"<<endl;
}
int main()
{
A a;
a.Test();
}
Which of the following statements is false regarding inline function in C++?
What is the output of C++ program given below?
#include<iostream> using namespace std; class Parent1 { public: int a=10; }; class Parent2 { public: int a=5; }; class Child:public Parent1,public Parent2 { public: int func() { return a; } }; int main() { Child ch; cout<<ch.func(); }
What is the output of C++ program given below?
#include<iostream> using namespace std; class Parent { public: void func() { cout<<"function of Parent"<<endl; } }; class Child:public Parent { public: void func() { cout<<"function of Child"<<endl; } }; int main() { Child ch; ch.func(); }
Choose the appropriate true statement among the given options with reference to C++ programming.
What is the output of C++ program given below?
#include<iostream>
using namespace std;
class Test
{
public:
int a=9;
void func()
{
cout<<a*a;
}
};
class Hello:public Test
{
public:
void func(int x)
{
cout<<a*x;
}
};
int main()
{
Hello obj;
obj.func(5);
}
What is the output of C++ program given below?
#include<iostream>
using namespace std;
class Test
{
protected:
int a=10,b=5;
public:
virtual int func()=0;
};
class Imp:public Test
{
public:
int func()
{
int x=++a*b++;
return x;
}
};
int main()
{
Imp i;
cout<<i.func();
}
What is the output of C++ program given below?
#include<iostream> using namespace std; class Test { public: mutable int a; /line1/ Test() /line2/ { a=10; /line3/ } void func() const /line4/ { a++; /line5/ cout<<a; } }; int main() { const Test obj; obj.func(); }
Identify the type of inheritance used in the following C++ code snippet.
class A { }; class B:public A { }; class C:public A { }; class D:public A { };
What is the output of C++ program given below?
#include<iostream>
using namespace std;
class Parent
{
public:
int a=10,b=20;
};
class Middle:protected Parent
{
public:
Middle()
{
a++;
b--;
}
};
class Child:private Middle
{
public:
int hello()
{
return a*b;
}
};
int main()
{
Child ch;
cout<<ch.hello();
}