Practice Memory Management –
What would be the output of the following?
#include
void main()
{
char *ptr=“abcd”
char ch;
ch = ++*ptr++;
cout<
}
Practice Memory Management –
What would be the output of the following?
#include
void main()
{
char *ptr=“abcd”
char ch;
ch = ++*ptr++;
cout<
}
What will be the output of the following program?
Practice Memory Management –
What will be the output of the following program?
#include
int main() {
int x = 10, y = 20;
int *ptr = &x;
int &ref = y;
*ptr++;
ref++;
cout<< x << " " << y;
return 0;
}
What will be the output of following program?
Practice Memory Management –
What will be the output of following program?
#include
void main()
{
float x;
x=(float)9/2;
cout<
}
Practice Memory Management –
What is the output of following program?
#include
using namespace std;
class A
{
private:
int x;
public:
A(int _x) { x = _x; }
int get() { return x; }
};
class B
{
static A a;
public:
static int get()
{ return a.get(); }
};
int main(void)
{
B b;
cout << b.get();
return 0;
}
Practice Memory Management –
What is the output of following program?
#include
using namespace std;
class Player
{
private:
int id;
static int next_id;
public:
int getID() { return id; }
Player() { id = next_id++; }
};
int Player::next_id = 1;
int main()
{
Player p1;
Player p2;
Player p3;
cout << p1.getID() << " ";
cout << p2.getID() << " ";
cout << p3.getID();
return 0;
}
Practice Memory Management –
What is the output of following program?
#include
using namespace std;
class Test
{
static int x;
public:
Test() { x++; }
static int getX() {return x;}
};
int Test::x = 0;
int main()
{
cout << Test::getX() << " ";
Test t[5];
cout << Test::getX();
}
Practice Memory Management –
Find the output of following program?
#include
class Test
{
public:
void fun();
};
static void Test::fun()
{
std::cout<<"fun() is static
";
}
int main()
{
Test::fun();
return 0;
}
Practice Memory Management –
Predict the output of following program.
#include
using namespace std;
class Test
{
private:
static int count;
public:
Test& fun();
};
int Test::count = 0;
Test& Test::fun()
{
Test::count++;
cout << Test::count << " ";
return *this;
}
int main()
{
Test t;
t.fun().fun().fun().fun();
return 0;
}
How “Late binding” is implemented in C++?
Practice Memory Management –
How “Late binding” is implemented in C++?
If we create a file by ‘ifstream’, then the default mod
Practice Memory Management –
If we create a file by ‘ifstream’, then the default mode of the file is ______________.
To perform stream I/O with disk files in C++, you should
Practice Memory Management –
To perform stream I/O with disk files in C++, you should
An array element is accessed using
Practice Memory Management –
An array element is accessed using
If an array is declared as
int a[4] = {3, 0, 1, 2}, then values
Practice Memory Management –
If an array is declared as
int a[4] = {3, 0, 1, 2}, then values assigned to a[0] & a[4] will be ________.
In C++, dynamic memory allocation is accomplished with the operator
Practice Memory Management –
In C++, dynamic memory allocation is accomplished with the operator ____________.
Which of the following jobs are NOT performed by a
Practice Memory Management –
Which of the following jobs are NOT performed by a Garbage Collector?