Showing posts with label Quiz. Show all posts

CS201 introduction to programing 300 quiz

Which of the following will be the correct function call for function prototype given
below?
int func (int &);
func(int num);
func(&num);
func(num);
func(*num);
If there is a symbol (& sign) used with the variable name followed by data type then it
refers to _____ and if & is being used with variable name then it refers to _____.
Address of variable, reference variable
Reference variable, value of variable
Reference variable, address of variable
Address of variable, value of variable
Which of the following operator the compiler overloads for objects by default?
+ operator
- operator
= operator
== operator
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
14
If overloaded plus operator is implemented as member function then which of the
following option will be true for the statement given below?
obj3 = obj1 + obj2 ;
obj1 will be passed as an argument to + operator whereas obj2 will drive the +
operator
obj1 will drive the + operator whereas obj2 will be passed as an argument to +
operator
Both objects (obj1, obj2) will be passed as arguments to the + operator
Any of the objects (obj1, obj2)can drive the + operator
The operator function will be implemented as _____, if both objects (obj1, obj2) are
passed as arguments to - operator in the statement given below.
obj3 = obj1 - obj2;
friend function
member function
non-member function
either non-member or friend function
The input/output streams cin and cout are ________ therefore have _______.
Structures, function
Objects, member functions
Functions, objects
None of the given options
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
15
What will be the output of following statement?
cout << setfill(‘0’) << setw(7) << 128
0000128
0128128
1280000
0012800
The static data members of a class will be ________
shared by objects
created for each object
initialized within class
initialized within main function
Which of the following is used for allocating space for static variables?
Heap
Static storage area
Free store
Stack
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
16
Templates provide way of abstracting ______________ information.
type
data
method
access
A pointer is a special type of variable that contain ___________
Memory Address
Data values
Both Values and Memory
None of given of options
Which is NOT a protection level provided by classes in C++?
protected
hidden
private
public
Users must not know about ____________________.
Functions Name within Class
Class implementation of Functionality and Interfaces
Methods Functionality with in Class
None of the given options
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
17
Assignment operator is used to initialize a newly declared object from existing object
True
False
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
tA template function must have
One or more than one arguments
Only one argument
Zero arguments
None of the given options
Truth tables are usedfor analyzing ___________.
logical expressions
arithmetic expressions
both logical and arithmetic expressions
none of the given options.
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
18
Which of the following array is the most suitable for storing a matrix structure?
Single-dimensional array
Two-dimensional array
Three-dimensional array
Four-dimensional array
How many bytes are occupied by declaring following array of characters?
char str[] = “programming”;
10
11
12
13
11 bytes for 11characters of word programming and 1 for '\n'
When we do dynamic memory allocation in the constructor of a class, then it is necessary
to provide a destructor.
True
False
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
19
The prototype of friend functions must be written ____ the class and its definition must
be written ____
inside, inside the class
inside, outside the class
outside, inside the class
outside, outside the class
Copy constructor becomes necessary while dealing with _______allocation in the class.
Dynamic memory
Static memory
Both Dynamic and Static memory
None of the given options
Dealing with structures and functions passing by reference is the most economical
method
True
False
1st...what is the function of flush commond?
1):when we specify the buffer size, normallythe operating system or compiler does this
for us. A typical size of buffer is 512 bytes. When the information is of 512 byte size,
output will take place. But in the program, we may want at some point that whatever is in
the buffer, show them. For that purpose the normal mechanism is flush. Flush the stream.
The flush command forces the data from the buffer to go to its destination which is
normally a screen or file and make the buffer empty.  Lec 34
2nd...what are the types of tamplates?
a template is a sketch to draw some shape or figure.
There are two different types of templates in C++ language i.e.’ function templates
and class templates.  Lec 41
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
20
The declarator of Plus (+) member operator function is
Class-Name operator + (Class-Name rhs)
operator Class-Name + ( )
operator Class-Name + ( rhs)
Class-Name operator + ( )
12 & 8 = (1000) 2 =________. & is usedto AND two numbers bit-wise
Select correct option:
4
8
6
12
Is ka answer 8 hy, see handouts page number 246.
Truth table for &
Bit1 Bit2 Bit1 & Bit2
1 1 1
1 0 0
0 1 0
0 0 0
Therefore, when we apply the conditions, we get
12 = 1 1 1 0 (binary conversion of 12)
8 = 1 0 0 0 (binary conversion of 8)
------------------------------------------------------------
1 0 0 0, which is equals to 8
The reserved words public and private comes under the category
Which of the following operators can not be overloaded?
1) :new
2) :delete
3) :+=
4) :sizeof
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
21
The reserved words public and private comes under the category
1) :structures
2) :strings
3) :accessibility modifiers
4) :types of functions
Question No: 10 ( Marks: 1 ) - Please choose one
What is the sequence of event(s) whenallocating memory using new operator?
Only block of memory is allocated for objects
Only constructor is called for objects
Memory is allocated first before calling constructor
Constructor is called first before allocating memory
Question No: 11 ( Marks: 1 ) - Please choose one
What is the sequence of event(s) when deallocating memory using delete operator?
Only block of memory is deallocated for objects
Only destructor is called for objects
Memory is deallocated first before calling destructor
Destructor is called first before deallocating memory
Question No: 12 ( Marks: 1 ) - Please choose one
newand deleteoperators cannot be overloaded as member functions.
True
False
Question No: 13 ( Marks: 1 ) - Please choose one
The operator function of << and >> operators are always the member function of a
class.
True
False
Question No: 14 ( Marks: 1 ) - Please choose one
A template function must have at least ---------- generic data type
Zero
One
Two
Three
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
22
Question No: 15 ( Marks: 1 ) - Please choose one
If we do not mention any return_value_type with a function, it will return an _____
value.
int
void
double
float
Question No: 16 ( Marks: 1 ) - Please choose one
Suppose a program contains an array declared as int arr[100];what will be the size of
array?
0
99
100
101
Question No: 17 ( Marks: 1 ) - Please choose one
The name of an array represents address of first location of array element.
True
False
Question No: 18 ( Marks: 1 ) - Please choose one
Reusing the variables in programhelps to save the memory
True
False
Question No: 19 ( Marks: 1 ) - Please choose one
Which of the following option is true aboutnew operator to dynamically allocate
memory to an object?
The new operator determines the size of an object
Allocates memory to object and returns pointer of valid type
Creates an object and calls the constructor to initialize the object
All of the given options
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
23
Question No: 20 ( Marks: 1 ) - Please choose one
new and delete are _____ whereas malloc and free are _____.
Functions, operators
Classes, operators
Operators, functions
Operators, classes
Question No: 21 ( Marks: 1 ) - Please choose one
Like member functions, ______ can also access the private data members of a class.
Non-member functions
Friend functions
Any function outside class
None of the given options
Question No: 22 ( Marks: 1 ) - Please choose one
Which of the following statement is best regarding declaration of friend function?
Friend function must be declared after public keyword.
Friend function must be declared after private keyword.
Friend function must be declared at the top within class definition.
It can be declared anywhere in class as these are not affected by the public and
private keywords.
Question No: 23 ( Marks: 1 ) - Please choose one
The operator function overloaded for anAssignment operator (=) must be
Non-member function of class
Member function of class
Friend function of class
None of the given options
Question No: 24 ( Marks: 1 ) - Please choose one
For non-member operator function, object on left side of the operator may be
Object of operator class
Object of different class
Built-in data type
All of the given options
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
24
Question No: 25 ( Marks: 1 ) - Please choose one
The operator function will be implemented as_____, if obj1 drive the - operator whereas
obj2 is passed as arguments to - operator in the statement given below.
obj3 = obj1 - obj2;
Member function
Non-member function
Friend function
None of the given options
Question No: 26 ( Marks: 1 ) - Please choose one
Which one of the following is the declaration of overloaded pre-increment operator
implemented as member function?
Class-name operator +() ;
Class-name operator +(int) ;
Class-name operator ++() ;
Class-name operator ++(int) ;
Question No: 27 ( Marks: 1 ) - Please choose one
The static data members ofa class are initialized _______
at file scope
within class definition
within member function
within main function
Question No: 28 ( Marks: 1 ) - Please choose one
Class is a user defined___________.
data type
memory referee
value
none of the given options.
Question No: 29 ( Marks: 1 ) - Please choose one
We can also define a user-defines manipulators.
True
False
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
25
Question No: 30 ( Marks: 1 ) - Please choose one
Automatic variable are created on ________.
Heap
Free store
static storage
stack
Question No: 3 ( Marks: 1 ) - Please choose one
A pointer variable can be,
Decremented only
Incremented only
Multiplied only
Both 1 and 2
Question No: 4 ( Marks: 1 ) - Please choose one
setprecision is a parameter less manipulator.
True
False
Question No: 5 ( Marks: 1 ) - Please choose one
We can change a Unary operator to Binary operator through operator overloading.
False
True
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
26
What is the functionality of the following statement?
String str[5] = {String(“Programming”), String(“CS201”)};
Default constructor will call for all objects of array
Parameterized constructor will call for all objects of array
Parameterized constructor will call for first 2 objects and default constructor for
remaining objects
Default constructor will call for first 3 objects and Parameterized constructor for
remaining objects
There is an array of characters having name ‘course’ that has to be initialized by string
‘programming’ which of the following is the correct way to do this,
i.course[] = {‘p’, ’r’, ’o’, ’g’, ’r’, ’a’, ’m’, ’m’, ’i’, ’n’, ’g’};
ii.course[] = ‘programming’ ;
iii.course[12] = “programming” ;
iv.  course = “programming” ;
Choose the correct options.
(i) and (ii) only
(i) and (iv) only
(i) and (iii) only
(ii) and (iii) only
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
27
Overloaded member operator function is always called by _______
Class
Object
Compiler
Primitive data type
Consider the following code segment
class M {
friend int operator!(const M &);
...
};
!s  // code of line implies that operator!(s)
...
Let assume if s is an object of the class then function is implemented as ___________
Member function
Non-member function
Binary operator function
None of the given options
None of the given options
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
28
Copy constructor becomes necessary while dealing with _______allocation in the class.
Dynamic memory
Static memory
Both Dynamic and Static memory
None of the given options
1)C/C++ string constant is enclosed in Small braces
Curly braces
Double quote
Single quote
2)Unary operator takes argument
Zero
One
Two
Three
3)When define array of objects
Constructor will call
Destructor will call
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
29
The size of int data type is
1 bytes
2 bytes
3 bytes
4 bytes
In Flow chart process is represented by
Rectangle
Arrow symbol
Oval
Circle
If the break statement is missed in switch statement then,
The compiler will give error
This may cause a logical error
No effect on program
Program stops its execution
When we are using const keyword with a variable x then initializing it at the time of
declaration is,
Must
Optional
Not necessary
A syntax error
Which of the following is the correct way to assign an integer value 5 to element of a
matrix say ‘m’ at second row and third column?
m[2][3] = 5 ;
m[3][2] = 5 ;
m[1][2] = 5 ;
m[2][3] = ‘5’;
How many total elements must be in two-dimensional array of 3 rows and 2 columns?
4
5
6
7
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
30
Which of the following is the correct statement for the following declaration?
const int *ptr.
ptr is a constant pointer
ptr is constant integer pointer
  ptr is a constant pointer to int
ptr is a pointer to const int
Consider the following code segment. What will be the output of this code segment?
int arr[6] = {2, 3, 7, 4, 5, 6} ;
int *ptr1 =&arr[1] ;
int *ptr2 = &arr[4] ;
cout << (ptr2-ptr1) ;
3
9
12
2
What will be the correct syntax to assign an array named arr of 5 elements to a pointer
ptr?
*ptr = arr ;
ptr = arr ;
  *ptr = arr[5]  ;
ptr = arr[5] ;
The variables having a name, type and size are just like empty boxes.
False
True
What's wrong with this for loop?
for (int k = 2, k <=12, k++)
the increment should always be ++k
the variable must always be the letter i when using a for loop
there should be a semicolon at the end of the statement
the commas should be semicolons
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
31
Most efficient method of dealing with structure variables is to define the structure
globally
True
False
Syntax of union is identical to ______
Structure
Class
Function
None of the given options
Like member functions, ______ can also access the private data members of a class.
Non-member functions
Friend functions
Any function outside class
None of the given options
Function created with in function called?
nested
overloaded
grouped
none of them
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
Which of the following will be the correct function call for function prototype given
below?
int func (int &);
func(int num);
func(&num);
func(num);
func(*num);
If there is a symbol (& sign) used with the variable name followed by data type then it
refers to _____ and if & is being used with variable name then it refers to _____.
Address of variable, reference variable
Reference variable, value of variable
Reference variable, address of variable
Address of variable, value of variable
Which of the following operator the compiler overloads for objects by default?
+ operator
- operator
= operator
== operator
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
14
If overloaded plus operator is implemented as member function then which of the
following option will be true for the statement given below?
obj3 = obj1 + obj2 ;
obj1 will be passed as an argument to + operator whereas obj2 will drive the +
operator
obj1 will drive the + operator whereas obj2 will be passed as an argument to +
operator
Both objects (obj1, obj2) will be passed as arguments to the + operator
Any of the objects (obj1, obj2)can drive the + operator
The operator function will be implemented as _____, if both objects (obj1, obj2) are
passed as arguments to - operator in the statement given below.
obj3 = obj1 - obj2;
friend function
member function
non-member function
either non-member or friend function
The input/output streams cin and cout are ________ therefore have _______.
Structures, function
Objects, member functions
Functions, objects
None of the given options
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
15
What will be the output of following statement?
cout << setfill(‘0’) << setw(7) << 128
0000128
0128128
1280000
0012800
The static data members of a class will be ________
shared by objects
created for each object
initialized within class
initialized within main function
Which of the following is used for allocating space for static variables?
Heap
Static storage area
Free store
Stack
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
16
Templates provide way of abstracting ______________ information.
type
data
method
access
A pointer is a special type of variable that contain ___________
Memory Address
Data values
Both Values and Memory
None of given of options
Which is NOT a protection level provided by classes in C++?
protected
hidden
private
public
Users must not know about ____________________.
Functions Name within Class
Class implementation of Functionality and Interfaces
Methods Functionality with in Class
None of the given options
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
17
Assignment operator is used to initialize a newly declared object from existing object
True
False
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
tA template function must have
One or more than one arguments
Only one argument
Zero arguments
None of the given options
Truth tables are usedfor analyzing ___________.
logical expressions
arithmetic expressions
both logical and arithmetic expressions
none of the given options.
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
18
Which of the following array is the most suitable for storing a matrix structure?
Single-dimensional array
Two-dimensional array
Three-dimensional array
Four-dimensional array
How many bytes are occupied by declaring following array of characters?
char str[] = “programming”;
10
11
12
13
11 bytes for 11characters of word programming and 1 for '\n'
When we do dynamic memory allocation in the constructor of a class, then it is necessary
to provide a destructor.
True
False
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
19
The prototype of friend functions must be written ____ the class and its definition must
be written ____
inside, inside the class
inside, outside the class
outside, inside the class
outside, outside the class
Copy constructor becomes necessary while dealing with _______allocation in the class.
Dynamic memory
Static memory
Both Dynamic and Static memory
None of the given options
Dealing with structures and functions passing by reference is the most economical
method
True
False
1st...what is the function of flush commond?
1):when we specify the buffer size, normallythe operating system or compiler does this
for us. A typical size of buffer is 512 bytes. When the information is of 512 byte size,
output will take place. But in the program, we may want at some point that whatever is in
the buffer, show them. For that purpose the normal mechanism is flush. Flush the stream.
The flush command forces the data from the buffer to go to its destination which is
normally a screen or file and make the buffer empty.  Lec 34
2nd...what are the types of tamplates?
a template is a sketch to draw some shape or figure.
There are two different types of templates in C++ language i.e.’ function templates
and class templates.  Lec 41
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
20
The declarator of Plus (+) member operator function is
Class-Name operator + (Class-Name rhs)
operator Class-Name + ( )
operator Class-Name + ( rhs)
Class-Name operator + ( )
12 & 8 = (1000) 2 =________. & is usedto AND two numbers bit-wise
Select correct option:
4
8
6
12
Is ka answer 8 hy, see handouts page number 246.
Truth table for &
Bit1 Bit2 Bit1 & Bit2
1 1 1
1 0 0
0 1 0
0 0 0
Therefore, when we apply the conditions, we get
12 = 1 1 1 0 (binary conversion of 12)
8 = 1 0 0 0 (binary conversion of 8)
------------------------------------------------------------
1 0 0 0, which is equals to 8
The reserved words public and private comes under the category
Which of the following operators can not be overloaded?
1) :new
2) :delete
3) :+=
4) :sizeof
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
21
The reserved words public and private comes under the category
1) :structures
2) :strings
3) :accessibility modifiers
4) :types of functions
Question No: 10 ( Marks: 1 ) - Please choose one
What is the sequence of event(s) whenallocating memory using new operator?
Only block of memory is allocated for objects
Only constructor is called for objects
Memory is allocated first before calling constructor
Constructor is called first before allocating memory
Question No: 11 ( Marks: 1 ) - Please choose one
What is the sequence of event(s) when deallocating memory using delete operator?
Only block of memory is deallocated for objects
Only destructor is called for objects
Memory is deallocated first before calling destructor
Destructor is called first before deallocating memory
Question No: 12 ( Marks: 1 ) - Please choose one
newand deleteoperators cannot be overloaded as member functions.
True
False
Question No: 13 ( Marks: 1 ) - Please choose one
The operator function of << and >> operators are always the member function of a
class.
True
False
Question No: 14 ( Marks: 1 ) - Please choose one
A template function must have at least ---------- generic data type
Zero
One
Two
Three
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
22
Question No: 15 ( Marks: 1 ) - Please choose one
If we do not mention any return_value_type with a function, it will return an _____
value.
int
void
double
float
Question No: 16 ( Marks: 1 ) - Please choose one
Suppose a program contains an array declared as int arr[100];what will be the size of
array?
0
99
100
101
Question No: 17 ( Marks: 1 ) - Please choose one
The name of an array represents address of first location of array element.
True
False
Question No: 18 ( Marks: 1 ) - Please choose one
Reusing the variables in programhelps to save the memory
True
False
Question No: 19 ( Marks: 1 ) - Please choose one
Which of the following option is true aboutnew operator to dynamically allocate
memory to an object?
The new operator determines the size of an object
Allocates memory to object and returns pointer of valid type
Creates an object and calls the constructor to initialize the object
All of the given options
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
23
Question No: 20 ( Marks: 1 ) - Please choose one
new and delete are _____ whereas malloc and free are _____.
Functions, operators
Classes, operators
Operators, functions
Operators, classes
Question No: 21 ( Marks: 1 ) - Please choose one
Like member functions, ______ can also access the private data members of a class.
Non-member functions
Friend functions
Any function outside class
None of the given options
Question No: 22 ( Marks: 1 ) - Please choose one
Which of the following statement is best regarding declaration of friend function?
Friend function must be declared after public keyword.
Friend function must be declared after private keyword.
Friend function must be declared at the top within class definition.
It can be declared anywhere in class as these are not affected by the public and
private keywords.
Question No: 23 ( Marks: 1 ) - Please choose one
The operator function overloaded for anAssignment operator (=) must be
Non-member function of class
Member function of class
Friend function of class
None of the given options
Question No: 24 ( Marks: 1 ) - Please choose one
For non-member operator function, object on left side of the operator may be
Object of operator class
Object of different class
Built-in data type
All of the given options
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
24
Question No: 25 ( Marks: 1 ) - Please choose one
The operator function will be implemented as_____, if obj1 drive the - operator whereas
obj2 is passed as arguments to - operator in the statement given below.
obj3 = obj1 - obj2;
Member function
Non-member function
Friend function
None of the given options
Question No: 26 ( Marks: 1 ) - Please choose one
Which one of the following is the declaration of overloaded pre-increment operator
implemented as member function?
Class-name operator +() ;
Class-name operator +(int) ;
Class-name operator ++() ;
Class-name operator ++(int) ;
Question No: 27 ( Marks: 1 ) - Please choose one
The static data members ofa class are initialized _______
at file scope
within class definition
within member function
within main function
Question No: 28 ( Marks: 1 ) - Please choose one
Class is a user defined___________.
data type
memory referee
value
none of the given options.
Question No: 29 ( Marks: 1 ) - Please choose one
We can also define a user-defines manipulators.
True
False
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
25
Question No: 30 ( Marks: 1 ) - Please choose one
Automatic variable are created on ________.
Heap
Free store
static storage
stack
Question No: 3 ( Marks: 1 ) - Please choose one
A pointer variable can be,
Decremented only
Incremented only
Multiplied only
Both 1 and 2
Question No: 4 ( Marks: 1 ) - Please choose one
setprecision is a parameter less manipulator.
True
False
Question No: 5 ( Marks: 1 ) - Please choose one
We can change a Unary operator to Binary operator through operator overloading.
False
True
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
26
What is the functionality of the following statement?
String str[5] = {String(“Programming”), String(“CS201”)};
Default constructor will call for all objects of array
Parameterized constructor will call for all objects of array
Parameterized constructor will call for first 2 objects and default constructor for
remaining objects
Default constructor will call for first 3 objects and Parameterized constructor for
remaining objects
There is an array of characters having name ‘course’ that has to be initialized by string
‘programming’ which of the following is the correct way to do this,
i.course[] = {‘p’, ’r’, ’o’, ’g’, ’r’, ’a’, ’m’, ’m’, ’i’, ’n’, ’g’};
ii.course[] = ‘programming’ ;
iii.course[12] = “programming” ;
iv.  course = “programming” ;
Choose the correct options.
(i) and (ii) only
(i) and (iv) only
(i) and (iii) only
(ii) and (iii) only
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
27
Overloaded member operator function is always called by _______
Class
Object
Compiler
Primitive data type
Consider the following code segment
class M {
friend int operator!(const M &);
...
};
!s  // code of line implies that operator!(s)
...
Let assume if s is an object of the class then function is implemented as ___________
Member function
Non-member function
Binary operator function
None of the given options
None of the given options
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
28
Copy constructor becomes necessary while dealing with _______allocation in the class.
Dynamic memory
Static memory
Both Dynamic and Static memory
None of the given options
1)C/C++ string constant is enclosed in Small braces
Curly braces
Double quote
Single quote
2)Unary operator takes argument
Zero
One
Two
Three
3)When define array of objects
Constructor will call
Destructor will call
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
29
The size of int data type is
1 bytes
2 bytes
3 bytes
4 bytes
In Flow chart process is represented by
Rectangle
Arrow symbol
Oval
Circle
If the break statement is missed in switch statement then,
The compiler will give error
This may cause a logical error
No effect on program
Program stops its execution
When we are using const keyword with a variable x then initializing it at the time of
declaration is,
Must
Optional
Not necessary
A syntax error
Which of the following is the correct way to assign an integer value 5 to element of a
matrix say ‘m’ at second row and third column?
m[2][3] = 5 ;
m[3][2] = 5 ;
m[1][2] = 5 ;
m[2][3] = ‘5’;
How many total elements must be in two-dimensional array of 3 rows and 2 columns?
4
5
6
7
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
30
Which of the following is the correct statement for the following declaration?
const int *ptr.
ptr is a constant pointer
ptr is constant integer pointer
  ptr is a constant pointer to int
ptr is a pointer to const int
Consider the following code segment. What will be the output of this code segment?
int arr[6] = {2, 3, 7, 4, 5, 6} ;
int *ptr1 =&arr[1] ;
int *ptr2 = &arr[4] ;
cout << (ptr2-ptr1) ;
3
9
12
2
What will be the correct syntax to assign an array named arr of 5 elements to a pointer
ptr?
*ptr = arr ;
ptr = arr ;
  *ptr = arr[5]  ;
ptr = arr[5] ;
The variables having a name, type and size are just like empty boxes.
False
True
What's wrong with this for loop?
for (int k = 2, k <=12, k++)
the increment should always be ++k
the variable must always be the letter i when using a for loop
there should be a semicolon at the end of the statement
the commas should be semicolons
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
31
Most efficient method of dealing with structure variables is to define the structure
globally
True
False
Syntax of union is identical to ______
Structure
Class
Function
None of the given options
Like member functions, ______ can also access the private data members of a class.
Non-member functions
Friend functions
Any function outside class
None of the given options
Function created with in function called?
nested
overloaded
grouped
none of them
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents

Almost 300 Solved MCQs of CS201



w1
Almost 300 Solved MCQs of CS201
By
Default constructor takes _________.
one parameter
two parameters
no parameters
character type parameter
All the preprocessors directives start with ________.
$
&
#
_
The members of a class declared with the keyword struct are _____________by default.
static
private
protected
public
Loops are _______________ Structure
Decision
Sequential
Repetition
None of the given options
We cannot use ______________ pointer for storing and reading data fromit.
NULL
integer
double
zero
2
When an object of a class is defined inside another class then,
Destructor of enclosing class will be called first
Destructor of inner object will be called first
Constructor and Destructor will be called simultaneously
None of the given options
Consider the following code segment. Which of the following will be called while
executing code at line 2? String s1 , s2; s1 = s2 ;
Copy constructor
Default constructor
Assignment operator
Parameterized constructor
We cannot increment ________________.
pointers
arrays
references
variables
In statement Matrix m2 = m1 ;
Assignment operator is being used
Copy constructor is being used.
Statement has syntax error
None of the given options
From the following; which on is the correct syntax of an array declaration: array size is 5
and it is of float data type?
float [5] name;
name[5] float;
float name[5];
None of the given options
If an array has 50 elements, what isallowable range of subscripts?
0 – 49
1 – 49
0 – 50
1 – 50
3
A structure is a collection of _____________under a single name.
values
variables
data
None of the given
If a function has not been declaredbefore its definition, It is a
logical error
syntax error
run time error
None of these
When the if statement consists more than onestatement then enclosing these statement in
curly braces is,
Not required
Good programming
Relevant
Must
__________ allow us to have a memory location and use it as int or char interchangeably
structures
union
construct
None of the given
In Analysis, we try to have a______________
Determined the inputs
Break up of problem
Precise problem statement
None of the given
_______________function give the position of the next character to be read from that
file.
tellp()
tellg()
seekg()
seekp()
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
4
Pointers store the ____________________
value of a variable
memory address
characters
None of the given
In order to get the right most digit of a number, we divide this number by 10 and take its
Remainder
Quotient
Divisor
None of the given options
___________ 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 )
If int a = 50; then the value of a/= 3; will be,
15
18
16
17
_______________________ contains functions for manipulations of character data.
ctype.h
iostream.h
string.h
None of the given
____________________ Returns true if c is a digit ora letter and false otherwise.
int isalpha( int c )
int isalnum( int c )
int isxdigit( int c )
int isdigit( int c )
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
5
Ifint sum = 54; Then the value of the following statement is sum = sum - 3 ;
52
50
51
57
To get the value stored at a memory address, we use the________________
referencing operator
dereferencing operator
simple operator
None of the given
In C/C++; by default arguments are passed by _______ to a function.
Reference
Value
Type
Data
The string in the array is terminated by a _______
zero
nil
null
one
Structures are syntacticallydefined with the word_____________.
struc
struct
structure
None of the given
C is widely known as development language of _______ operating system.
Linux
Unix
Windows
Mac OS
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
6
At the___________, we try to break up the problem into functional units
analysis phase
design phase
Implementation phase
None of the given
While developing a program; should wethink about the user interface?
Yes
No
What will be the result of arithmetic expression 5+25/5*5?
45
6
30
9
Why we use"cin"?
To send data to printer
To read data fromkeyboard
To display message
To display output on the screen
_________operator uses the sign ^.
Bit-wise OR
Exclusive OR
AND Operator
NOT operator
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
7
C++ is a_________________ language.
High level
Low level
Machine
Fourth Generation
12 & 8 = (1000) 2 =________. & is usedto AND two numbers bit-wise
4
8
6
12
Fromthe following; which one is used as an assignment operator?
Equal sign ‘=’
Double equal sign ‘==’
Both equal and double equal sign
None of the given options
What will be the value of ‘a’ and ‘b’ after executing the following statements? int a = 9;
int b = a++; cout<<
10,9
9,10
9,9
10,10
These functions seekg() and seekp() requires an argument of type ____________to let
them how many bytes to move forward or backward.
int
short
long
double
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
8
A character is stored in the memory in _________
byte
integer
string
None of the given
dereferencing operator is represented by _______
*
+
None of the given
______________ transfers the executable code frommain memory to hard disk.
Loader
Debugger
Compiler
Linker
When the logical operator OR(||) combine two expressions exp1 and exp2 then the result
will be false only,
When both exp1 and exp2 are true
When both exp1 and exp2 are false
When exp1 is true and exp2 is false
When exp1 is false and exp2 is true
suppose we have int y[10]; To access the 4th element of the array we write_________
y[4];
y[3];
y[2];
none of given
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
9
we have opened a file streammyfile for reading (getting), myfile.tellg () gives us the
current get position of the file pointer. It returns a whole number of type___________
long
int
short
double
ofstreamis used for________
Input file stream
Output file stream
Input and output file stream
All of the given
A structure is a collection of _____________under a single name.
values
variables
data
None of the given
The first character of a variable name must be an alphabet or
Underscore
Digit
Special character
Comma
Suppose int multi[5][10];when we are using **multi , it means,
Single dereferencing
Single referencing
Double referencing
Double dereferencing
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
10
eof( ), bad( ), good( ), clear( ) all are manipulators.
True
False
It is possible to return anobject from a function through thispointer.
True
False
Function implementation of friend function must be defined outside the class.
True
False
The default scope for members of structures is publicwhereas the default visibility for
class members is private.
True
False
The operator function of << and >> operators are always the member function of a class.
True
False
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
11
How many bytes are occupied by declaring following array of characters?
char str[] = “programming”;
10
11
12
13
What does STL stand for?
Source template library
Standard template library
Stream template library
Standard temporary library
Which of the following array is the most suitable for storing a matrix structure
Single-dimensional array
Two-dimensional array
Three-dimensional array
Four-dimensional array
What will be the output of following code segment?
main(){
int x = 5 ;
{
int x = 4 ;
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
12
cout << x << “,” ;
}
cout << x ;
}
5, 5
4, 4
4, 5
5, 4
Single line comments explaining code would bepreceded like in the following example.
/*
//
/
//*
The ________ statement interrupts the flow of control.
switch
continue
goto
break
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
13



w1
Almost 300 Solved MCQs of CS201
By
Default constructor takes _________.
one parameter
two parameters
no parameters
character type parameter
All the preprocessors directives start with ________.
$
&
#
_
The members of a class declared with the keyword struct are _____________by default.
static
private
protected
public
Loops are _______________ Structure
Decision
Sequential
Repetition
None of the given options
We cannot use ______________ pointer for storing and reading data fromit.
NULL
integer
double
zero
2
When an object of a class is defined inside another class then,
Destructor of enclosing class will be called first
Destructor of inner object will be called first
Constructor and Destructor will be called simultaneously
None of the given options
Consider the following code segment. Which of the following will be called while
executing code at line 2? String s1 , s2; s1 = s2 ;
Copy constructor
Default constructor
Assignment operator
Parameterized constructor
We cannot increment ________________.
pointers
arrays
references
variables
In statement Matrix m2 = m1 ;
Assignment operator is being used
Copy constructor is being used.
Statement has syntax error
None of the given options
From the following; which on is the correct syntax of an array declaration: array size is 5
and it is of float data type?
float [5] name;
name[5] float;
float name[5];
None of the given options
If an array has 50 elements, what isallowable range of subscripts?
0 – 49
1 – 49
0 – 50
1 – 50
3
A structure is a collection of _____________under a single name.
values
variables
data
None of the given
If a function has not been declaredbefore its definition, It is a
logical error
syntax error
run time error
None of these
When the if statement consists more than onestatement then enclosing these statement in
curly braces is,
Not required
Good programming
Relevant
Must
__________ allow us to have a memory location and use it as int or char interchangeably
structures
union
construct
None of the given
In Analysis, we try to have a______________
Determined the inputs
Break up of problem
Precise problem statement
None of the given
_______________function give the position of the next character to be read from that
file.
tellp()
tellg()
seekg()
seekp()
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
4
Pointers store the ____________________
value of a variable
memory address
characters
None of the given
In order to get the right most digit of a number, we divide this number by 10 and take its
Remainder
Quotient
Divisor
None of the given options
___________ 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 )
If int a = 50; then the value of a/= 3; will be,
15
18
16
17
_______________________ contains functions for manipulations of character data.
ctype.h
iostream.h
string.h
None of the given
____________________ Returns true if c is a digit ora letter and false otherwise.
int isalpha( int c )
int isalnum( int c )
int isxdigit( int c )
int isdigit( int c )
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
5
Ifint sum = 54; Then the value of the following statement is sum = sum - 3 ;
52
50
51
57
To get the value stored at a memory address, we use the________________
referencing operator
dereferencing operator
simple operator
None of the given
In C/C++; by default arguments are passed by _______ to a function.
Reference
Value
Type
Data
The string in the array is terminated by a _______
zero
nil
null
one
Structures are syntacticallydefined with the word_____________.
struc
struct
structure
None of the given
C is widely known as development language of _______ operating system.
Linux
Unix
Windows
Mac OS
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
6
At the___________, we try to break up the problem into functional units
analysis phase
design phase
Implementation phase
None of the given
While developing a program; should wethink about the user interface?
Yes
No
What will be the result of arithmetic expression 5+25/5*5?
45
6
30
9
Why we use"cin"?
To send data to printer
To read data fromkeyboard
To display message
To display output on the screen
_________operator uses the sign ^.
Bit-wise OR
Exclusive OR
AND Operator
NOT operator
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
7
C++ is a_________________ language.
High level
Low level
Machine
Fourth Generation
12 & 8 = (1000) 2 =________. & is usedto AND two numbers bit-wise
4
8
6
12
Fromthe following; which one is used as an assignment operator?
Equal sign ‘=’
Double equal sign ‘==’
Both equal and double equal sign
None of the given options
What will be the value of ‘a’ and ‘b’ after executing the following statements? int a = 9;
int b = a++; cout<<
10,9
9,10
9,9
10,10
These functions seekg() and seekp() requires an argument of type ____________to let
them how many bytes to move forward or backward.
int
short
long
double
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
8
A character is stored in the memory in _________
byte
integer
string
None of the given
dereferencing operator is represented by _______
*
+
None of the given
______________ transfers the executable code frommain memory to hard disk.
Loader
Debugger
Compiler
Linker
When the logical operator OR(||) combine two expressions exp1 and exp2 then the result
will be false only,
When both exp1 and exp2 are true
When both exp1 and exp2 are false
When exp1 is true and exp2 is false
When exp1 is false and exp2 is true
suppose we have int y[10]; To access the 4th element of the array we write_________
y[4];
y[3];
y[2];
none of given
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
9
we have opened a file streammyfile for reading (getting), myfile.tellg () gives us the
current get position of the file pointer. It returns a whole number of type___________
long
int
short
double
ofstreamis used for________
Input file stream
Output file stream
Input and output file stream
All of the given
A structure is a collection of _____________under a single name.
values
variables
data
None of the given
The first character of a variable name must be an alphabet or
Underscore
Digit
Special character
Comma
Suppose int multi[5][10];when we are using **multi , it means,
Single dereferencing
Single referencing
Double referencing
Double dereferencing
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
10
eof( ), bad( ), good( ), clear( ) all are manipulators.
True
False
It is possible to return anobject from a function through thispointer.
True
False
Function implementation of friend function must be defined outside the class.
True
False
The default scope for members of structures is publicwhereas the default visibility for
class members is private.
True
False
The operator function of << and >> operators are always the member function of a class.
True
False
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
11
How many bytes are occupied by declaring following array of characters?
char str[] = “programming”;
10
11
12
13
What does STL stand for?
Source template library
Standard template library
Stream template library
Standard temporary library
Which of the following array is the most suitable for storing a matrix structure
Single-dimensional array
Two-dimensional array
Three-dimensional array
Four-dimensional array
What will be the output of following code segment?
main(){
int x = 5 ;
{
int x = 4 ;
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
12
cout << x << “,” ;
}
cout << x ;
}
5, 5
4, 4
4, 5
5, 4
Single line comments explaining code would bepreceded like in the following example.
/*
//
/
//*
The ________ statement interrupts the flow of control.
switch
continue
goto
break
smart solution
Best Blog To Help VUStudents
smart solution
Best Blog To Help VUStudents
13

CS201- Introduction to Programming exam Quiz



Question No: 1      ( Marks: 1 ) - Please choose one
 

A precise sequence of steps to solve a problem is called

       Statement

       Program

       Utility

       Routine


Question No: 1      ( Marks: 1 ) - Please choose one
 

A precise sequence of steps to solve a problem is called

       Statement

       Program

       Utility

       Routine