0% found this document useful (0 votes)
476 views16 pages

CS201 Quiz-3 by Vu Topper RM-2

Uploaded by

sadiajahangir789
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
476 views16 pages

CS201 Quiz-3 by Vu Topper RM-2

Uploaded by

sadiajahangir789
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 16

CS-201 Quiz -3 File

By Vu Topper RM
When a variable is defined as static in a class then _____________.
Only one copy is created for all objects of this class
In C++ operators, which of the following operator cannot be overloaded
___________.
(?:)
Automatic variable are created on ________.
STACK
Consider the following code segment. Which of the following will be
called while executing code at line 2?String s1 , s2;s1 = s2 ;
Assignment operator
Which of the following is normally a source for cin stream?
Keyboard
Which of the following functionality can be achieved through
overloading?
New operators cannot be defined through operator overloading.
Assignment operator is used to initialize a newly declared object from
existing object.
True
False
Overloaded delete operator function takes parameter of void pointer and
returns.
VOID(NOTHING)
Which of the following is a destination of cout stream?
PRINTER

For More Help Contact What’s app 03224021365


When an operator function is defined as member function for a Unary
operator then the number of extra arguments it takes is/are,
One
Static data members of a class can be ____________.
public and private
The operator function for << (stream insertion) >> and stream extraction
must be
Non-member function of class
The only operator that the compiler overloads for user define data type
by default is
Assign operator
It is possible to return an object from function using this pointer.
True
False
The statement cin.get (); is used to________.
Read a string from keyboard
Read a character from keyboard (Page 426)
Read a string from file
Read a character from file

The stream-insertion operator is >> and the stream-extraction operator is


<<.
True
False
Within the statement obj1=obj2; obj1 will call the assignment operator
function and obj2 will be passed as an argument to function.
True
False
Let suppose a = b = c In such situation, it is necessary to return a
reference of an object from assignment operator function.

For More Help Contact What’s app 03224021365


True
False

When an array of object is created dynamically then there is no way to


provide parameterized constructors for array of objects.
True
False
When new operator is overloaded at global level then corresponding
built-in new operator will also be visible to whole of the program.
True
False
C++ offers type-safe I/O. The << and >> operators are overloaded to
accept data items of specific types.
True
False

When an operator function is defined as member function for a binary


Plus (+) operator then the number of extra arguments it takes is/are.
One
N arguments
Zero

The get member function, when passed no arguments, inputs an entire


stream and returns it as the value of the function call.?
False
True

ostream is a _______________ operator.


Member
None

For More Help Contact What’s app 03224021365


Dependent
Standalone

Overloaded member operator function is always called by ___


Class
Compiler
Primitive data types
Object
The second parameter of operator function for >> operator must always
be passed
By reference
None of the given option
Function takes no argument
By value

If text is a pointer of type String then what will be the functionality of


following statement?text = new string [5];
Creates array of 5 objects dynamically
Creates a string object
Creates array of 5 objects statistically
Creates array of of pointer to string

When operator function is implemented as member function then return


type of function ____.
Must be an object of same class
Must be user defined data type
Must be built – in data type
Can be any data type

For More Help Contact What’s app 03224021365


Which of the following syntax is best used to delete an array of 5 objects
named ‘string’ allocated using new operator.
delete string [1];
delete string [5];
delete string ;
delete [] string;

What is the difference between cout and cerr?


Cout is standard output and cerr is not a standard output
Cout is buffered output and cerr is not a unbuffered output
Cout is not standard output and cerr is a standard output
Cout is unbuffered output and cerr is a buffered output

We cannot define friends for the _____ that are already written and not
in our control.
Destructor
Classes
Constructors
Functions

What will be the output of the following code segment?


Float pi=32.3996;
Cout<<fixed;
Cout<<setprecision(2)<<pi;

32.00
32.39
32.40
32.310

For More Help Contact What’s app 03224021365


With user data type variables (Objects) self assignment can produce
Logical error
Run time error
Link error
Syntax error

When an operator function is defined as member function for a binary


Plus (+) operator then the number of extra arguments it takes is/are.
One
N arguments
Zero

The get member function, when passed no arguments, inputs an entire


stream and returns it as the value of the function call.?
False
True

ostream is a _____ operator.


Member
None
Dependent
Standalone

Overloaded member operator function is always called by ___


Class
Compiler
Primitive data types
Object
The second parameter of operator function for >> operator must always
be passed

For More Help Contact What’s app 03224021365


By reference
None of the given option
Function takes no argument
By value

If text is a pointer of type String then what will be the functionality of


following statement?text = new string [5];
Creates array of 5 objects dynamically
Creates a string object
Creates array of 5 objects statistically
Creates array of of pointer to string

When operator function is implemented as member function then return


type of function ____.
Must be an object of same class
Must be user defined data type
Must be built – in data type
Can be any data type

Which of the following syntax is best used to delete an array of 5 objects


named ‘string’ allocated using new operator.
delete string [1];
delete string [5];
delete string ;
delete [] string;

What is the difference between cout and cerr?


Cout is standard output and cerr is not a standard output
Cout is buffered output and cerr is not a unbuffered output
Cout is not standard output and cerr is a standard output

For More Help Contact What’s app 03224021365


Cout is unbuffered output and cerr is a buffered output

We cannot define friends for the _____ that are already written and not
in our control.
Destructor
Classes
Constructors
Functions

What will be the output of the following code segment?


Float pi=32.3996;
Cout<<fixed;
Cout<<setprecision(2)<<pi;

32.00
32.39
32.40
32.310

With user data type variables (Objects) self assignment can produce
Logical error
Run time error
Link error
Syntax error

C++ provides member functions, which control the formatting to be


performed during stream I/O operations.
True
False

For More Help Contact What’s app 03224021365


In overloading the assignment (=) operator, which object(s) will call the
operator function?
Left object of the assignment operator
Both object will call the operator function
Right object of the assignment operator
No object will call the operator function

The ws manipulator can be used with __ stream(s).


None of the given option
Output
Input/output
Input

The only operator that the compiler overloads for user define data type
by default is
Plus (+) operator
Minus (-) operator
Equal (==) operator
Assignment (=) operator

When we use cin stream to read some number from the keyboard and
store it in the integer variable, then what will happen?
Its to ASCII code will be stored inside the computer
Some error will occure and cin stream will detect this error
Its binary representation will be ignored and the value will be stored
Its binary representation will be ignored and the character will be stored

*this is a pointer that always points to


Current object of the class
Current pointer of the class

For More Help Contact What’s app 03224021365


Current function of the clas
A value of data member

Overloaded member operator function is always called by ___


Compiler
Object
Class
Primitive data types

If operator function is non-member function then object on left side of


operator cannot be_____?
Object of member function
Built-in data type
Object of operator class
Object of different class

What is the purpose of endl stream manipulator?


Terminate a string with null
Insert a new line
Flush the stream
Insert a new line and flush the stream

Overloaded assignment operator must be


Friend function of class
Global function
Member function of class
Non-member function of class

C++ offers type-safe I/O. The << and >> operators are overloaded to
accept data items of specific types.\

For More Help Contact What’s app 03224021365


False
True

For the joining of two strings in string class, we may use “+” operator,
can we use “-” operator the same way for subtracting strings?
Yes along “?” operator only
Yes along “+”operator only
Yes
No

:: is called _____.
One’s complement operator
Bitwise OR
Scope resolution operator
Condition operator

The stream insertion and extraction operators are not already overloaded
for __
Both built –in and user – defined types
User- defined data types
Built-in data types
None of the given option

In C++ operators, which of the following operator cannot be overloaded


_____.
-
?
+
<<

For More Help Contact What’s app 03224021365


Automatic variable are created on ____.
Static storage
Heap
Free store
Stack

When we used eof (end of file) with the file reading than which of the
following is a true statement?
This is a way to check type of the stream
This is a way to check destination of the stream
This is a way to check source of the stream
This is a way to check state of the stream

Which one of the following is the declaration of overloaded pre-


increment operator implemented as member function?
Class –name operator ++(int);
Class –name operator ++();
Class –name operator +();
Class –name operator +(int);

The first parameter of operator function for << operator _______.


Must be object class
Must be passed by value
Can be passed by value or reference
Must be passed by reference

ostream class is ____ and not under our control.


User-defined
Built-in
Both

For More Help Contact What’s app 03224021365


None

Which of the following functionality can be achieved through


overloading?
We can change the precedence of same operator
We can change associativity of all operator
New operator cannot be defined through operator overloading
We can change the assosiativity of some operator

The operator function for << (stream insertion) >> and stream extraction
must be
Non –member function of class
Member function of class
Both member and non-member function
None of given option

Static variable which is defined in a function is initialized ____.


Compile time of programe
None of the above
Only once during its life time
Every time the function call

Overloaded delete operator function takes parameter of void pointer and


returns.
Void pointer
Int pointer
Object pointer
Void (nothing)

_____ must be included to use stream manipulator in your code.

For More Help Contact What’s app 03224021365


Iostream
Stdlib.h
Iomanip
Conio.h

Consider the following code segment. Which of the following will be


called while executing code at line 2?
String s1,s2;
S1=s2;
Parameterized constructor
Assignment operator
Default operator
Copy constructor

Consider the following code, the printed value will be converted into:
int n = 10;
cout<<oct<<n;
base 2
base 8
base 10
decimal number system

Which of the following is normally a destination for cin stream?


Mouse
Keyboard
Printer
Variable

Which of the following is a destination of cout stream?


Constant

For More Help Contact What’s app 03224021365


Variable
Data type
Printer

The return type of the operator function for << operator is ____.
Void
Reference of ostrem class(ostream&)
Reference of ostrem class(istream&)
Class which we overload operator

Static data members of a class can be ____.


Public
Private
Public and private
None

If we do not write our own assignment operator then which of the


following problem may occur?
Dangling pointer
Memory leak
Unreferenced memory
Null pointer
____________ variables are defined in the main.
Local
What is the sequence of event(s) when allocating memory to an object
using new operator?
Memory is allocated first before calling constructor
The endl and flush are _______
Manipulators
A variable which is defined inside a function is called

For More Help Contact What’s app 03224021365


Automatic variable
Deleting an array of objects without specifying [] brackets may lead to
memory leak.
False
True

For More Help Contact What’s app 03224021365

You might also like