Sunteți pe pagina 1din 35

janji ajahttps://titanpad.

com/qyifVfwXkk

In C++, ____ is called the scope resolution operator.


.

::

->

==

Consider the following definition of the recursive function recFunc.


int recFunc(int num)
{
if (num >= 10)
return 10;
else
return num * recFunc(num + 1);
}
What is the output of the following statement?
cout << recFunc(8) << endl;
48

720

72

A function is called ____ if it calls itself.


function definition

function overloading

indirectly recursive

directly recursive

x
When a function is declared as inline and main calls that function, then
function call is not possible

error

compiler directly goes to that function's definition

function code is expanded in main


A variable listed in a function call is known as ____ parameter. A variable list in a
definition is known as ____ parameter
actual; formal

actual; actual

formal; actual

formal; formal

By default the members of a structure are


Private

Public

Protected

all of the above

Find the output of following


int main()
{
int a=46;
cout.fill('#');
cout.width(7);
cout<<a;
}
46#####

46

#####46

##46

There is a unique function in C++ program by where all C++ programs start their
execution
Start

Main

Include

Getch
The file iostream includes
The streams of includes and outputs of program effect.

The declarations of the basic standard input-output library.

both a and b

none of these

The file iostream includes


The streams of includes and outputs of program effect.

The declarations of the basic standard input-output library.

both a and b

none of these
Considering the following declarations:
const int N 10;
int array[N];
Considering the following declarations:
const int N 10;
int array[N];
cout<<array[6]

cout<<array[7]

cout<<array

none of these

Identify the correct statement


Programmer can use comments to include short explanations within the source
code itself.

All lines beginning with two slash signs are considered comments.

Comments very important effect on the behaviour of the program

Both a and b

In function overloading, on which basis the functions can be differentiated


Number of parameters

Order of parameters

type of parameters

All of the above

Which is false in case of pointers arithmetic


Pointers can be added

Pointers can be subtracted

Pointers can be incremented

Pointers can be decremented

Given following declarations


int x=10,y=10;
int *p1=&x,*p2=&y;
What will be the value of cout<<++(*p2)-*p1;
0

-1

None of these

Printing value of *(&i) is same as printing the value of


&

cannot access

error

The pointer that is not initialized is


void pointer

wild pointer

null pointer

dangling pointer
A pointer that can hold the address of any type of variable is
null pointer

wild pointer

void pointer

none of these

In which of the following methods for function call, the changes made in formal
arguments are reflected in actual arguments
Call by address

Call by value

Call by reference

Both a and c

A pointer is holding address of a variable that has been deleted from memory, such
type of pointer is called
null pointer

dangling pointer

pointer to pointer

void pointer

Find the output of following


int main()
{
string s1="abc",s2="xyz";
cout<<s1.length();
s1.swap(s2);
cout<<s1<<s2;
getch();
}
6 abc xyz

3 xyz abc

6 xyz abc

3 abc xyz
Considering the following declarations:
void *p;
float abc;
Which of the following C++ statements will correctly print the value of variable abc using
pointer p
cout<<*p

cout<<*(int*)p

cout<<*(float*)p

error

10) Find the output of follwing:


int main()
{
int i=3;
int *j;
int **k;
j=&i;
k=&j;
cout<<i<<j<<k;
}
Address Address 3

Address Address Address

3 Address 3

3 Address Address

11) How can we declare a pointer to a pointer of int type?


a) *(int*) p;
b) void p;
c) int *p;
d) int **p;

12)

What is the output of the following code?


int *p;
int x;
x = 76;
p = &x;
*p = 43;
cout << x << ", " << *p << endl;
43,43

76,43

43,76

76,76

13) Consider the following declaration string str;. Which of the following statements stores
"Blue Sky" into str?
a) str="blue"
b) str="Blue Sky"
c) str="sky"
d) str="blue_sky"
Write a program to show the use of possible operations on pointers.
Differentiate between call by value, call by address, and call by reference by taking a
example.
Differentiate between wild, null, void, and dangling pointer with examples.
Write a program to insert an element in array by making use of pointer.

Unit 3:

The members of a class are by default


Public

Private

Protected

Both a and b

Conversion operators have ____ explicit argument(s) and ____ explicit return type.
one, no

one, an

no, no

no, an

The objects of a class can directly access


Private members
Public members

Protected members

All of the above

4) If count is static data member and item is a class, then


int item::count;
What is the value of count initially?
Zero

Error

One

No value

5) A non member function that can access private data of class is known as
a) Static function
b) Library function
c) Friend function
d) All of the above

6) A method used to initialize an object’s instance variables when the object is created is
called ___
a) Constructor
b) Mutator
c) Creator
d) Accessor

7) Constructor and destructor are automatically invoked by


a) Compiler
b) Operating system
c) Main function
d) object

8) Which of the following operator functions may be written as a friend function?


a) +
b) –
c) *
d) All of the above
9) The operator function returns value of
a) void type
b) basic type
c) class type
d) All of the above

One of the following operators cannot be overloaded


plus operator

dot operator

& operator

– operator

Constructors have same name as


the current program

The class they belong to

always class name starting with ~

none of these
By default, all member functions defined inside the class are treated as
inline functions

friend functions

Main function

none of these

The size of object is


Null

Default

Total size of member functions

Total size of data variables


A ____ is a programmer-created data type.
user defined

bulit in

global

primitive

What is static data member in class? Show how it can be accessed in class by writing a
suitable program.
What is constructor? Differentiate between default, parametrized and copy constructor by
taking example.

When you derive a class privately, a protected base class member becomes
Private
Public
not inherited
None of these

The statement infile.seekg(0,ios::end) sets the file pointer to


middle of file
beginning of file
end of file
none

The eof stands for


error of file
end of file
error opening file
none

Which among following is used to open a file in binary mode ?


ios::put
ios::out
ios::in
ios::binary

The close() function


ends the file
closes the file
empty the file
all of above

In the code fout.open("scores.dat", ios::out);


opens file in write mode
opens file in read mode
opens file in binary mode
none

The object of fstream class provides


only read operation
only write operation
both read and write operations
none
ifstream fin; would be used when
reading a file
writing a file
removing a file
creating a file

To add data at the end of the file, the file should be opened in
write mode
read mode
append mode
insert mode

When a file is opened in read or write mode, the file pointer is set to
not set
middle of file
end of file
beginning of file

Which stream class is to only read from files ?


Ifstream
Ofstream
Fstream
None

The constructor of the following class requires a file name and mode for opening a file
Ifstream
Ofstream
Fstream
None

Unit 1
Concepts and Basics of C++ Programming : Reading and writing data using cin
and cout, Creating classes, Class objects, Accessing class members, Differences
between Structures, Unions, Enumerations and Classes, Inline and Non-inline
member functions, Static data members and static member functions
Functions and Input/output Streams : Functions with Default
parameters/arguments, Inline Functions, Features of Input/output Streams,
Manipulators Functions, Function overloading and Scope rules, Friend of a class
(friend function and friend class), Differences between Call by value, Call by address
and call by reference, Recursion

Which value will it take when both user and default values are given?

a) user value
b) default value
c) custom value
d) none of the mentioned

In which of the following should the methods of a class differ if they are to be treated as
overloaded methods?
1. Type of arguments
2. Return type of methods
3. Number of arguments
4. Names of methods
5. Order of arguments
a)1, 3, 5
b) 3, 4
c) 1,2,3,4,5
d) 2,4
Which of the following statement will be correct if the function has three arguments
passed to it?
A) The trailing argument will be the default argument.
B) The first argument will be the default argument
C) The middle argument will be the default argument
D) All the argument will be the default argument

Which of the following function declaration is/are incorrect?


a) int Sum(int a, int b);
b) int Sum(inta,intb);
c)int Sum(int a = 0, b);
d)both b and c

What is the syntax of friend class?


a) friend class Class2;
b) friend class;
c) friend class;
d) None of the mentioned

What is the syntax of friend function?


a) friend void sum();
b) friend sum();
c) void sum ()friend ;
d) friend :: void sum();

Predict the output:


a = 200;
b = 300;
cout << setfill ( ‘ * ’ );
cout << setw (5) << a << setw (5) << b << endl;
a) **200**300
b) 200**300**
c) 200 300
d) 200300

Predict the output:


a = 20;
b = 30;
cout << setfill ( ‘ * ’ );
cout << setw (5) << a << setw (5) << b << endl;
a) ***20***30
b) 200***30***
c) 20 30
c) 2030
In the following code, in which order the functions would be called? x =
f1(23,14)*f2(12/4)+f3();
A. f1, f2, f3
B. f3, f2, f1
C. The order may vary from compiler to compiler
D. none of these

In the following code, in which order the functions would be called? x = f1()*20+f2();
A. f1, f2
B. f2, f1
C. The order may vary from compiler to compiler
D. none of these

Where the return statement does returns the execution of the program?
a) main function
b) caller function
c) same function
d) none of the mentioned

What are mandatory parts in function declaration?


a) return type,function name
b) return type,function name,with/without parameters
c) both a and b
d) none of the mentioned

The operator used with cout is called:


a. Insertion operator
b. Extraction operator
c. Get operator
d. Comparison operator

The operator used with cin is called:


a. Insertion operator
b. Extraction operator
c. Get operator
d. Comparison operator

We cannot use __________ members outside the class


a. Public
b. private
c. Protected
d. Local
The default access specifier of class is:
a. Private
b. Public
c. Protected
d. Local

How to declare a static data member?


a. int static a;
b. int a;
c. static a;
d. static int a;

What is true for static member function?


a. It uses only static data members.
b. It is called using class name and scope resolution operator.
c. Separate memory is allocated for member for every object.
d. Both a and b.

Find the output:


class test
{
static int item;
public:
void set()
{
cout<<++item;
}
}ob1,ob2;
int test :: item;
int main()
{
ob1.set();
ob2.set();
}
a. 00
b. 01
c. 12
d. 22

Find the output:


class test
{
static int item;
public:
void set()
{
cout<<++item;
}
}ob1,ob2;
int test :: item=1;
int main()
{
ob1.set();
ob2.set();
}
a. 11
b. 33
c. 23
d. 22

Find the output:


class test
{
int code;
public:
static void set()
{
cout<<++code;
}
}ob1,ob2;
int main()
{
test::set();
test::set();
}
a. 00
b. 01
c. 12
d. error
Ans: d

Find the output:


class A
{
int b;
public:
static void set()
{ b=10;
cout<<++b;
}
}ob1,ob2;
int main()
{
A::set();
A::set();
}
a. 10 1 0
b. 10 11
c. 11 1 2
d. error
Ans: d

Suppose we have to call a function fact using call by reference by passing two actual
parameters a and b, the following statement will be used by the calling function:
a) fact(a, b);
b) fact(*a, *b);
c) fact(&a, &b);
d) none of the above

Suppose we have to call a function fact using call by address by passing two actual
parameters a and b, the following statement will be used by the calling function:
a) fact(a, b);
b) fact(*a, *b);
c) fact(&a, &b);
d) none of the above

Which of the following function call is used as a default call in C++.


a) Call by value
b) Call by address
c) Call by pointer
d) Call by reference

Call by value uses the following concept


a) It passes the actual variable with alternative name
b) It passes the address of the variable
c) It passes the copy of the actual variable
d) None of the above

If a is a pointer holding the address of variable x, which of the following will print the
address of a.
a.cout<<a;
b. cout<<*a;
c. cout<<&a;
d. cout<<*x;
unit 2
Pointers, Reference Variables, Arrays and String Concepts : Use of pointer and
reference variables, Void pointer, Pointer arithmetic, Pointer to pointer, Possible
problems with the use of pointers - Dangling pointer, Wild pointer, Null pointer
assignment, Classes containing pointers, Pointer to objects, this pointer, Pointer to a
member,
Array declaration and processing of multidimensional arrays, Array of objects,
The Standard C++ string class-defining and assigning string objects, Member functions,
Modifiers of string class

The operator used for dereferencing is ____


a) *
b) &
c) ->
d) –>>
The operator used for indirection is ____
a) *
b) &
c) ->
d) –>>

Choose the right option


string * x, y;
a) x is a pointer to a string, y is a string
b) y is a pointer to a string, x is a string
c) both x and y are pointer to string types
d) none of the mentioned
Choose the right option
int * x, y;
a) x is a pointer to a integer, y is a integer
b) y is a pointer to a integer, x is a integer
c) both x and y are pointer to integer types
d) none of the mentioned

Which of the following is illegal?


a) int *ip;
b) string s, *sp = 0;
c) int i; double* dp = &i;
d) int *pi = 0;

Which of the following is illegal?


a) float *p;
b) string s, *sp = 0;
c) int i; float* dp = &i;
d) int *pi = 0;

What will happen in this last line of the code?


int a = 100, b = 200;
int *p = &a, *q = &b;
p = q;
a) b is assigned to a
b) p now points to b
c) a is assigned to b
d) q now points to a

What will happen in this last line of the code?


int a = 100, b = 200;
int *p = &a, *q = &b;
q=p;
a) a is assigned to b
b) p now points to b
c) b is assigned to a
d) q now points to a

If an array is declared as
int a[4] = {3, 0, 1, 2}, then values assigned to
a[1] & a[3] will be ________
A. 0,2
B. 1,3
C. 3, 0
D. 3,1

If an array is declared as
int a[4] = {1, 0, 4, 2}, then values assigned to
a[2] & a[3] will be ________
A. 4,2
B. 0,4
C. 2, 3
D. 1,0
The ____ operator is used to extract the address for a variable.
a. address (&) c. pointer (^)
b. assignment (=) d. indirection (*)

The & operator is used to extract the _______for a variable.


a. value c. both value and address
b. address d. none of these

The pointer used in the following program is known as:


int main(){
int *ptr,a;
cout<<ptr;
return 0;}
constant pointer b) void pointer c) null pointer d) wild pointer

The pointer used in the following program is known as:


int main(){
void *p;
int a=10;
p=&a;
cout<<*(int *)ptr;
return 0;}
constant pointer b) void pointer c) null pointer d) wild pointer

What is the output of following program:


#include <iostream>
using namespace std;
int main()
{
char *ptr;
char Str[] = "abcdefg";
ptr = Str;
ptr += 5;
cout << ptr;
return 0;
}
a) fg
b) cdef
c) defg
d) abcd

What is the output of following program:


#include <iostream>
using namespace std;
int main()
{
char *ptr;
char Str[] = "abcdefg";
ptr = Str;
ptr += 4;
cout << ptr;
return 0;
}
a) efg
b) defg
c)abcd
d) cdegf
What is the output of this program?
#include <iostream>
int main()
{
char arr[20];
int i;
for(i = 0; i < 10; i++)
*(arr + i) = 65 + i;
*(arr + i) = '\\0';
cout << arr;
return(0);
}
a) ABCDEFGHIJ
b) 012345678
c) 123456789
d) abcdefghij

What is the output of this program?


#include <iostream>

int main()
{
char arr[20];
int i;
for(i = 0; i < 10; i++)
*(arr + i) = 97 + i;
*(arr + i) = '\\0';
cout << arr;
return(0);
}
a) abcdefghij
b) 123456789
c) 012345678
d) ABCDEFGHIJ

Which of the following declares a pointer to a pointer to an integer?


a. int& p; d. int** p;
b. int&& p;
c. int* p;

Which of the following declares a pointer to a pointer to a float?


a. float & p; d. float ** p;
b. float && p;
c. float * p;

Given a two-dimensional array of five rows and ten columns, which of the following
array index notations is equivalent to the following expression when i is 3 and j is 6
:*(*(ary + i) + j)
a. ary[][10] d. *ary
b. ary[*][10]
c. ary[i][j]
Given a two-dimensional array of five rows and ten columns, which of the following
array index notations is equivalent to the *(*(ary + i) + j)
a. ary[][10] d. *ary
b. ary[*][10]
c. ary[i][j]

What is the output of following program :


#include<iostream>
#include<conio.h>
using namespace std;
class Simple
{
public:
int a;
};
int main()
{
Simple obj;
Simple* ptr;
ptr = &obj;
obj.a=10;
cout << ptr->a;
getch();
}
1 b. 0 c. 10 d. error

What is the output of following program:


#include<iostream>
#include<conio.h>
using namespace std;
class Simple
{
public:
int a;
};
int main()
{
Simple obj;
Simple* ptr;
ptr = &obj;
obj.a=11;
cout << ptr->a;
getch();
}
1 b. 0 c. 11 d. error

What is the output of following program:


#include<iostream>
#include<conio.h>
using namespace std;
class data
{ public:
void simple()
{
cout<<"Hello";
}
};
main()
{
data obj,*p;
p=&obj;
p->simple();
getch();
}
simple b. address of obj c. Hello d. hello

What is the output of following program:


#include<iostream>
#include<conio.h>
using namespace std;
class data
{ public:
void simple()
{
cout<<"Hi";
}
};
main()
{
data obj,*p;
p=&obj;
p->simple();
getch();
}
hI b. hi c. Hi d. HI
unit 3
Constructors, Destructors and File Handling : Manager functions (constructors
and destructor), Default constructor, Parameterized constructor, Copy constructor,
Dynamic constructors , Initializer lists, Constructor with default arguments,
Destructors
Data File operations : Opening and closing of files, Modes of file, File stream
functions, Reading/Writing of files, Sequential access and random access file
processing, Binary file operations, Classes and file operations, Structures and file
operation

Which type of data file is analogous to an audio cassette tape?


a. random access file b. sequential access file
c. binary file d. source code file

Which of the following header files is required for creating and reading data files?
a. ofstream.h b. fstream.h c. ifstream.h d. console.h

eof( ) is the function used for


[a] asserting no errors in a file
[b] appending data to a file
[c] counting the amount of data in a file
[d] checking for end of file

In the code fout.open("scores.dat", ios::out);


[a] ios::out is the stream operation mode.
[b] fout is the header file reference.
[c] ios::out is the stream variable name.
[d] fout is the name of the file.

ifstream fin; would be used when


[a] creating a file
[b] reading a file
[c] appending a file
[d] removing a file

ofstream fin; would be used when


[a] writing a file
[b] reading a file
[c] closing a file
[d] removing a file

Which stream class is to only write on files ?


ofstream

ifstream

fstream
d. iostream
Which stream class is to only read from files ?
a. ofstream
b. ifstream
c. fstream
d. iostream

Which stream class is used to both read and write on files ?


ofstream

ifstream

fstream

iostream

Which among following is used to open a file in binary mode ?


ios:app

ios::out

ios::in

ios::binary

ios::trunc is used for ?


If the file is opened for output operations and it already existed, no action is
taken.
If the file is opened for output operations and it already existed, its previous
content is deleted and replaced by the new one.

If the file is opened for output operations and it already existed, then a new
copy is created.

None of above

Which is correct syntax ?


myfile:open ("example.bin", ios:;out);

myfile.open ("example.bin", ios::out);

myfile::open ("example.bin", ios:::out);

myfile.open ("example.bin", ios:out);

Which among following is correct syntax of closing a file in c++ ?


myfile$close();

myfile@close();

myfile:close();

myfile.close();

offset counted from the current position using ?


ios::cur b. ios::cr c.ios::curr d. ios::current

Which among is used for positioning relative to the beginning of a stream ?


a.ios::start b.ios::beg c.ios::begin d.ios::beginning

How to find the position at end of fileObject ?


fileObject.seekg( 0, ios::end );

fileObject.seekg( 0, ios::last );

fileObject.seekg( 0, ios::cur );

fileObject.seekg( 0, ios::beg );

A Constructor that does not have any parameters is called____________ Constructor.


a. Custom
b. Dynamic
c. Static
d. Default
ANSWER: Default

if default constructor is not defined, then how the objects of the class will be created?

a. The compiler will generate error


b. Error will occur at run-time.
c. Compiler provides its default constructor to build the object.
d. None of these

Which of the followings are true about constructors?

1. A class can have more than one constructor.


2. Their address can be referred.
3. Constructors cannot return values.
a. 1,2 b. 2,3 c.1,3 d. all of these

What happens when a class with parameterized constructors and having no default
constructor is used in a program and we create an object that needs a zero-argument
constructor?

A. Compile-time error.
B. Preprocessing error.
C. Runtime error.
D. Runtime exception.

Destructor has the same name as the constructor and it is preceded by ______ .

A. ! B. ?
C. ~ D. $

For automatic objects, constructors and destructors are called each time the objects

A. enter and leave scope


B. inherit parent class
C. are constructed
D. are destroyed ans:: a
Which constructor function is designed to copy objects of the same class type?

A. Create constructor
B. Object constructor
C. Dynamic constructor
D. Copy constructor ans

Which of the following statement is correct?

A. Constructor has the same name as that of the class.


B. Destructor has the same name as that of the class with a tilde symbol at the
beginning.
C. Both A and B. Ans :C
D. Destructor has the same name as the first member function of the class.

When are the Global objects destroyed?

A. When the control comes out of the block in which they are being used.
B. When the program terminates.
C. When the control comes out of the function in which they are being used.
D. As soon as local objects die.

Copy constructor must receive its arguments by __________ .

A. either pass-by-value or pass-by-reference


B. only pass-by-value
C. only pass-by-reference
D. only pass by address

A function with the same name as the class, but preceded with a tilde character (~) is
called __________ of that class.

A. constructor B. destructor
C. function D. object

Which of the following statement is correct?

A. Destructor destroys only integer data members of the object.


B. Destructor destroys only float data members of the object.
C. Destructor destroys only pointer data members of the object.
D. Destructor destroys the complete object.

__________ used to make a copy of one class object from another class object of the
same class type.

A. constructor
B. copy constructor
C. destructor
D. default constructor

Constructors __________ to allow different approaches of object construction.

A. cannot overloaded
B. can be overloaded
C. can be called
D. can be nested

Which of the following statement is correct?

A. A destructor has the same name as the class in which it is present.


B. A destructor has a different name than the class in which it is present.
C. A destructor always returns an integer.
D. A destructor can be overloaded.

Which of the following are NOT provided by the compiler?

A. Zero-argument Constructor
B. Destructor
C. Copy Constructor
D. Copy Destructor

If the programmer does not explicitly provide a destructor, then which of the following
creates an empty destructor?

A. Preprocessor
B. Compiler
C. Linker
D. main() function
Which of the following statement is correct about destructors?

A. A destructor has void return type.


B. A destructor has integer return type.
C. A destructor has no return type.
D. A destructors return type is always same as that of main().

Predict the output:


#include <fstream>
#include <iostream>
#include<conio.h>
using namespace std;
int main ()
{
char data[]="shikha";
int age=20;
ofstream outfile;
outfile.open("afile.dat");
outfile << data << endl;
outfile << age << endl;
outfile.close();
ifstream infile;
infile.open("afile.dat");
cout << "Reading from the file" << endl;
infile >> data;
cout << data << endl;
infile >> age;
cout << age<< endl;
infile.close();
getch();
return 0;
}
Reading from the file
Shikha
age 20
Reading from the file
name Shikha
age 20
Reading from the file
shikha
20
Reading from the file
name shikha
age 20
Predict the output:
#include <fstream>
#include <iostream>
#include<conio.h>
using namespace std;
int main ()
{
char name[]="rahul";
int age=21;
ofstream outfile;
outfile.open("afile.dat");
outfile << name << endl;
outfile << age << endl;
outfile.close();
ifstream infile;
infile.open("afile.dat");
cout << "Reading from the file" << endl;
infile >> name;
cout << name << endl;
infile >> age;
cout << age<< endl;
infile.close();
getch();
return 0;
}
Reading from the file
Rahul
age 21
Reading from the file
name Rahul
age 21
Reading from the file
rahul
21
Reading from the file
name rahul
age 21
Predict the output:
#include<iostream>
#include<conio.h>
using namespace std;
class prime
{
int a,k,i;
public:
prime(int x)
{
a=x;
}
void calculate()
{
k=1;
{
for(i=2;i<=a/2;i++)

if(a%i==0)
{
k=0;
break;
}
else
{
k=1;
}
}
}

void show()
{
if(k==1)
cout<<"\\n prime Number. ";
else
cout<<"\\n Not prime.";
}
};

main()
{

int a;
prime obj(5);
obj.calculate();
obj.show();
getch();
}
prime Number.

Not prime

prime number

Error

Predict the output:


#include<iostream>
#include<conio.h>
using namespace std;
class prime
{
int a,k,i;
public:
prime(int x)
{
a=x;
}
void calculate()
{
k=1;
{
for(i=2;i<=a/2;i++)

if(a%i==0)
{
k=0;
break;
}
else
{
k=1;
}
}
}

void show()
{
if(k==1)
cout<<"\\n prime Number. ";
else
cout<<"\\n Not prime.";
}
};
main()
{ int a;
prime obj(21);
obj.calculate();
obj.show();
getch();
}
prime Number.

Not prime

5 is prime number

error

Which of the following is true about the program given below?


#include<iostream>
#include<conio.h>
using namespace std;
class India
{
public:
India()
{
cout << "Republic";
}
~India()
{
cout << "Day";
}
};
int main()
{
{
India obj;
}
getch();
}
(a) The program will print Republic
(b) The program will Print Day
(c) The program will print RepublicDay
(d) Error

class ABC
{
int x, y;
public:
ABC(int xx)
{
x = ++xx;
}
~ABC()
{
cout << x - 1 << " ";
}
void Display()
{
cout << --x + 1 << " ";
}
};
int main()

 {

{
ABC obj(6);
obj.Display();
}
getch();
} (a) 65
(b) 55
(c) 75
(d) 77

int val = 0;
class ABC
{
public:
ABC()
{
cout<< ++val;
}
~ABC()
{
cout<< val--;
}
};
int main()
{
{
ABC obj1, obj2, obj3;
{
ABC obj4;
}
}
getch();
}

(a) 1234
(b) 4321
(c) 12344321
(d) 12341234

S-ar putea să vă placă și