CS201 Solved MCQ’s


The statement cout yptr will show the __________the yptr points to.
Value
Memory Address
Variabvle
None of given
char **argv can be read as__________________.
Pointer to Pimter
Pointer to Char
Pointer to Pointer to Char
None of given
_______________are conventional names of the command line parameters of the ‘main()’ function.
‘argb’ and ‘argv’
‘argc’ and ‘argv’
‘argc’ and ‘argu’
None of Given
___________ Returns true if c is a digit and false otherwise.
int isalpha( int c )
int isalnum( int c )
int isxdigit( int c )
int isdigit( int c )
In the case of pointer to pointer or _______________, the first pointer contains the address of the second pointer, which contains the address of the variable, which contains the desired value.
double dereference
Single dereference
dereference
None of the given
_______________________ contains functions for manipulations of character data.
ctype.h
iostream.h
string.h
None of the given
dereferencing operator is represented by _______
*
+

None of the given
In_________, we try to have a precise problem statement
Analysis
Design
Coding
None of the given
Memory allocated from heap or free store _____________________.
can be returned back to the system automatically
can be allocated to classes only
cannot be returned back unless freed explicitly using malloc and realloc
cannot be returned back unless freed explicitly using free and delete operators
Once the _______________ are created, they exist for the life time of the program
local variables
non static variables
static variables
automatic variables
Once the static variables are created, they exist for the life of the program. They do not die. So returning their reference is all right.
The members of a class declared with the keyword struct are _____________by default.
static
private
protected
public.
The members of a class declared with the keyword struct are public by default. A structure is inherited publicly by default.
If the memory in the free store is not sufficient ____________________.
Select correct option:
malloc function returns 1
malloc function returns 0
malloc functions returns NULL pointer
malloc function returns free space
if the memory in the free store is not sufficient enough to fulfill the request. malloc() function returns NULL pointer if the memory is not enough. In C++, 0 is returned instead of NULL pointer.
This reference to a variable can be obtained by preceding the identifier of a variable with ________________.
dot operator
ampersand sign &
^ sign
operator
Once an object is declared as a friend, _________________________.
it has access to all non-public members as if they were public
it has access to public members only
it has no access to data members of the class
it has to protected data members only
Reference variables must _________________.
not be initialized after they are declared
be initialized after they are declared
contain integer value
contain zero value
If the request of new operator is not fulfilled due to insufficient memory in the heap____________________.
the new operator returns 2
the new operator returns 1
malloc functions returns NULL pointer
malloc function returns free space
Reference is not really an address it is ______________.
a synonym
an antonym
a value
a number
If the request of new operator is not fulfilled due to insufficient memory in the heap ____________________.
the new operator returns 2
the new operator returns 1
the operator returns 0
free operator returns nothing
Functions declared with the _______________ specifier in a class member list are called friend functions of that class.
protected
private
Public
friend
Functions declared with the friend specifier in a class member list are called friend functions of that class. Classes declared with the friend specifier in the member list of another class are called friend classes of that class.
public or private keywords can be ____________
written only for once in the class or structure declaration
written multiple times in the class or structure declaration
written only twice in the class declaration
written outside the class
good practice is to write public or private keywords only once in the class or structure declaration, though there is no syntactical or logical problem in writing them multiple times.
The friend keyword provides access _____________.
in one direction only
in two directions
to all classes
to the data members of the friend class only
The friend keyword provides access in one direction only. This means that while OtherClass is a friend of ClassOne, the reverse is not true.
References cannot be uninitialized. Because it is impossible to _______________
reinitialize a pointer
reinitialize a reference
initialize a NULL pointer
cast a pointer
new operator can be used for ______________.
Select correct option:
only integer data type
only char and integer data types
integer , float, char and double data types
dot operator
Similarly, new operator can be used for other data types like char, float and double etc.
The destructor is used to ______________.
allocate memory
deallocate memory
create objects
allocate static memory
If we want to allocate memory to an array of 5 integers dynamically, the syntax will be _____________.
int *iptr ; iptr = new int[5] ;
integer iptr** ; iptr= new int[5]
int iptr ; iptr= int [5]
iptr= new[5]
Memory allocated from heap or free store _____________________.
can be returned back to the system automatically
can be allocated to classes only
cannot be returned back unless freed explicitly using malloc and realloc
cannot be returned back unless freed explicitly using free and delete operators
The memory allocated from free store or heap is a system resource and is not returned back to the system unless explicitly freed using delete or freeoperators.
Operator overloading is to allow the same operator to be bound to more than one implementation, depending on the types of the _________.
Select correct option:
Compilers
Operands
Function names
Applications
Operator overloading is to allow the same operator to be bound to more than one
implementation, depending on the types of the operands.
The operator to free the allocated memory using new operator is________________.
Select correct option:
free
del
delete
remove
The operator to free the allocated memory using new operator is delete. So whenever,
we use new to allocate memory, it will be necessary to make use of ‘delete’ to deallocate
the allocated memory.
The concept of friend function negates the concept of _________________.
Select correct option:
inheritance
polymorphism
persistence
encapsulation
New operator is used to allocate memory from the free store during ______________
Compile Time
Run Time
Link Time
None of above
To get the memory address of a variable we use _____

&

&&
*
|

If we have a program that writes the output data (numbers) to the disc, and if we collect the output Data and write it on the disc in one write operation instead of writing the numbers one by one. In the above situation the area where we will gather the number is called
Buffer
Stream
Memory
None of these
What functionality the following program is performing?
#include <iostream.h>
int main()
{
const int SIZE = 80;
char buffer[SIZE];
cout <<” Enter a sentence : “;
cin.getline(buffer, SIZE);
cout<<buffer <<endl;
system(“pause”);

}
objects are used respectively to read a sentence from the key board and then print it on the screen.
Using getline function
using character arrays
Doing nothing
The get member function, when passed no arguments, inputs an entire stream and returns it as the value of the function call.
True
False
New operator allocates memory from free store and returns ___________
Void
NULL
Nothing return
None of above
The statement cin.get (); is used to,
Read a character from keyboard
Read a an entire string
Read integer values
Read float values
Suppose int i = 10; then what will be the value of i after being converted in to octal value
10
12
14
16
Which of the following is a destination of cout stream?
Monitor /screen
Keyboard
Memory
None of these
Which of the following is the correct definition of streams ?
streams are memory locations
sequence of bytes are called streams
sequence of variables are called streams
sequence does not have any definition
Stream operators are heavily overloaded means , they allow to handle int and character data type only.
true
false
What functionality the following program is performing?
int main()
{
const int SIZE = 80;
char buffer[SIZE];
cout <<” Enter a sentence : “;
cin.getline(buffer, SIZE);
cout<<buffer <<endl;
system(“pause”);

}
read and write member functions of cin and cout objects are used respectively to read a sentence from the key board and then print it on the screen.
read and put member functions of cin and cout objects are used respectively to read a sentence from the key board and then print it on the screen.
get and write member functions of cout and cin objects are used respectively to read a sentence from the key board and then print it on the screen.
get and write member functions of cout and cin objects are used respectively to read a sentence from the key board and then print it on the screen.
Which of the following is a source for cout stream?
monitor / screen
keyboard
proccessor
none of these
If we use cin stream to read some value and store it in some integer variable and press some alphabet key instead of numeric keys. then what will happen?
Its binary representation will be ignored and the character will be stored
Its binary representation will be ignored and the value will be stored
Its ASCII code will be stored inside the computer
Some error will occur and cin stream will detect this error.
The endl and flush are _____
Functions
Operators
Manipulators
Objects
What is the difference between cout and cerr ?
cout is unbuffered output and cerr is buffered output
cout is standard output and cerr is not a standard output
cout is not a standard output and cerr is standard output
cout is buffered output and cerr is unbuffered output
The operator function for << (stream insertion) >> and stream extraction must be
Member function of class
Non-member function of class
Both member and non-member function
None of the given options
The pointer returned by the new operator points to ————— of memory chunks allocated by the new operator
First memory address
Second memory address
Last memory address
None of the above
When we used eof (end of file) with the file reading than which of the following is a true statement?
This is way to check source of the stream
This is way to check destination of the stream
This is way to check state of the stream
This is way to check type of the stream
The stream insertion and extraction operators are not already overloaded for ____
Built-in data types
User-defined data types
Both built-in and user-defined types
None of the given options
When a variable is defined as static in a class then ___________
Separate copy of this variable is created for each object
Only one copy is created for all objects of this class
A copy of this variable is created for only static objects.
None of the given options
Static variable which is defined in a function is initialized ________.
Only once during its life time
Every time the function call
Compile time of the program
None of the above

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s