Documente Academic
Documente Profesional
Documente Cultură
com/qyifVfwXkk
::
->
==
720
72
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
actual; actual
formal; actual
formal; formal
Public
Protected
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.
both a and b
none of these
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
All lines beginning with two slash signs are considered comments.
Both a and b
Order of parameters
type of parameters
-1
None of these
cannot access
error
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
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
3 Address 3
3 Address Address
12)
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:
Private
Protected
Both a and b
Conversion operators have ____ explicit argument(s) and ____ explicit return type.
one, no
one, an
no, no
no, an
Protected members
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
dot operator
& operator
– operator
none of these
By default, all member functions defined inside the class are treated as
inline functions
friend functions
Main function
none of these
Default
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
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
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
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
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
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
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 (*)
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
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]
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
ifstream
fstream
d. iostream
Which stream class is to only read from files ?
a. ofstream
b. ifstream
c. fstream
d. iostream
ifstream
fstream
iostream
ios::out
ios::in
ios::binary
If the file is opened for output operations and it already existed, then a new
copy is created.
None of above
myfile@close();
myfile:close();
myfile.close();
fileObject.seekg( 0, ios::last );
fileObject.seekg( 0, ios::cur );
fileObject.seekg( 0, ios::beg );
if default constructor is not defined, then how the objects of the class will be created?
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. Create constructor
B. Object constructor
C. Dynamic constructor
D. Copy constructor ans
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.
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
__________ 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
A. cannot overloaded
B. can be overloaded
C. can be called
D. can be nested
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?
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
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
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