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
0 comments: