Predict the output of following C++ program.
// Assume that integers take 4 bytes.
#include<iostream>
using namespace std;
class Test
{
static int i;
int j;
};
int Test::i;
int main()
{
cout << sizeof(Test);
return 0;
}
What is the output of following C++ program?
#include<iostream>
using namespace std;
class P {
public:
void print()
{ cout <<" Inside P::"; }
};
class Q : public P {
public:
void print()
{ cout <<" Inside Q"; }
};
class R: public Q {
};
int main(void)
{
R r;
r.print();
return 0;
}
1 Crore+ students have signed up on EduRev. Have you? Download the App |
What is the output of following program?
#include<iostream>
using namespace std;
int x = 1;
void fun()
{
int x = 2;
{
int x = 3;
cout << ::x << endl;
}
}
int main()
{
fun();
return 0;
}
Which of the following is true about virtual functions in C++.
Which of the following in Object Oriented Programming is supported by Function overloading and default arguments features of C++.
How to create a dynamic array of pointers (to integers) of size 10 using new in C++? Here, one can create a non-dynamic array using int *arr[10]
What is the output of the following program?
#include <iostream>
using namespace std;
int main()
{
int x = -1;
try {
cout << "Inside try \n";
if (x < 0)
{
throw x;
cout << "After throw \n";
}
}
catch (int x ) {
cout << "Exception Caught \n";
}
cout << "After catch \n";
return 0;
}
A member function can always access the data in __________ .
What is the output of the following program?
#include <iostream>
using namespace std;
class Test
{
int x;
Test() { x = 5;}
};
int main()
{
Test *t = new Test;
cout << t->x;
}
Predict the output.
#include<iostream>
using namespace std;
class abc {
public:
static int x;
int i;
abc() {
i = ++x;
}
};
int abc::x;
main() {
abc m, n, p;
cout<<m.x<<" "<<m.i<<endl;
}
What should be put in a try block?
1. Statements that might cause exceptions
2. Statements that should be skipped in case of an exception
What is the output of following program?
#include <stdio.h>
int main()
{
const int x;
x = 10;
printf("%d", x);
return 0;
}
What is the built in library function to compare two strings?
Predict the output.
class Test {
int x;
};
int main()
{
Test t;
cout << t.x;
return 0;
}
What is the output of following program?
#include <iostream>
using namespace std;
int fun(int=0, int = 0);
int main()
{
cout << fun(5);
return 0;
}
int fun(int x, int y)
{
return (x+y);
}
Which of the followings is/are automatically added to every class, if we do not write our own?
73 videos|7 docs|23 tests
|