CS201
Solved Quizes
Question No: 1 ( Marks: 1 ) - Please choose one
► Class
► Object
► Compiler
►Primitive data type
Question No: 2 ( Marks: 1 ) - Please choose one
Loader loads the executable code from hard disk to main memory.
► True
► False
Question No: 3 ( Marks: 1 ) - Please choose one
Which of the following is the correct C++ syntax to allocate space dynamically for an array of 10 int?
► new int(10) ;
► new int[10] ;
► int new(10) ;
► int new[10];
Question No: 4 ( Marks: 1 ) - Please choose one
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
Question No: 5 ( 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: 6 ( Marks: 1 ) - Please choose one
To perform manipulation with input/output, we have to include _____ header file.
► iostream.h
► stdlib.h
► iomanip.h
► fstream.h
Question No: 7 ( Marks: 1 ) - Please choose one
The endl and flush are _______
► Functions
► Operators
► Manipulators
► Objects
Question No: 8 ( Marks: 1 ) - Please choose one
If we want to use stream insertion and extraction operators with _______ then we have to overload these operators.
► int, float, double
► objects of class
► int, float, object
► int, char, float
Question No: 9 ( Marks: 1 ) - Please choose one
The static data members of a class can be accessed by ________
► only class
► only objects
► both class and objects
► none of given options
Question No: 10 ( Marks: 1 ) - Please choose one
Classes defined inside other classes are called ________ classes
► looped
► nested
► overloaded
► none of the given options.
Question No: 11 ( Marks: 1 ) - Please choose one
Which value is returned by the destructor of a class?
► A pointer to the class.
► An object of the class.
► A status code determining whether the class was destructed correctly
► Destructors do not return a value.
Question No: 12 ( Marks: 1 ) - Please choose one
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
Question No: 13 ( Marks: 1 ) - Please choose one
If text is a pointer of class String then what is meant by the following statement?
text = new String [5];
► Creates an array of 5 string objects statically
► Creates an array of 5 string objects dynamically
► Creates an array of pointers to string
► Creates a string Object
Question No: 14 ( Marks: 1 ) - Please choose one
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
Question No: 15 ( Marks: 1 ) - Please choose one
In functions that return reference, use __________variables.
► Local
► Global
► Global or static
► None of the given option
Question No: 16 ( Marks: 1 ) - Please choose one
What is the functionality of the following syntax to delete an array of 5 objects named arr allocated using new operator?
delete arr ;
► Deletes all the objects of array
► Deletes one object of array
► Do not delete any object
► Results into syntax error
Question No: 17 ( Marks: 1 ) - Please choose one
What is the sequence of event(s) when allocating 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 (Find it urself)
Question No: 18 ( 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 (Find it urself)
Question No: 19 ( Marks: 1 ) - Please choose one
new and delete operators cannot be overloaded as member functions.
► True
► False
Question No: 20 ( Marks: 1 ) - Please choose one
The operator function of << and >> operators are always the member function of a class.
► True
► False
Question No: 21 ( Marks: 1 ) - Please choose one
Which of the following option is true about new 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
Question No: 22 ( Marks: 1 ) - Please choose one
new and delete are _____ whereas malloc and free are _____.
► Functions, operators
► Classes, operators
► Operators, functions
► Operators, classes
Question No: 23 ( 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: 24 ( 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: 25 ( 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: 26 ( Marks: 1 ) - Please choose one
Class is a user defined___________.
► data type
► memory referee
► value
► none of the given options.
Question No: 27 ( Marks: 1 ) - Please choose one
The static data members of a class are initialized _______
► at file scope
► within class definition
► within member function
► within main function
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
From the following; which one is the range of Random number generator function rand()?
0 – 32768
1 – 32768
0 – 32767
1 – 32767
From following; which one is the correct syntax of an array initialize: Array size is 10 and it is of double data type to value 0?
arr[10] = {0.0};
double arr[10]= 0.0;
double arr[10] = {0.0};
double arr[] = 0.0;
The string in the array is terminated by a _____
zero
nil
null
one
y[4];
y[3];
y[2];
none of given
From the following; which one is the range of Random number generator function rand()?
0 – 32768
1 – 32768
0 – 32767
1 – 32767
From following; which one is the correct syntax of an array initialize: Array size is 10 and it is of double data type to value 0?
arr[10] = {0.0};
double arr[10]= 0.0;
double arr[10] = {0.0};
double arr[] = 0.0;
The string in the array is terminated by a _____
zero
nil
null
one
In C/C++; by default arguments are passed by _____ to a function.
Reference
Value
Type
Data
1
char name [] = “Hello World” ; In the above statement, a memory of _______ characters will be allocated
13
11
12
10
_______ Keyword is used to return some value from a function.
break
return
continue
goto
Which of the function call is call by value for the following function prototype? float add(int);
add(&x);
add(x);
add(int x);
add(*x);
The increment of a pointer depends on its_________.
variable
10
_______ Keyword is used to return some value from a function.
break
return
continue
goto
Which of the function call is call by value for the following function prototype? float add(int);
add(&x);
add(x);
add(int x);
add(*x);
The increment of a pointer depends on its_________.
variable
value
data type
None of the given
The ASCHI code of null character is_________
000
010
111
110
data type
None of the given
The ASCHI code of null character is_________
000
010
111
110
Pointers are a special type of __________in which a memory address is stored
Select correct option:
variables
Location
Characters
None of the given
Select correct option:
variables
Location
Characters
None of the given
just for copy paste
Transpose of a matrix means that when we interchange rows and columns_____________
Select correct option:
the first row becomes the Last column
the first row becomes the first column
the Last row becomes the first column
the first column becomes the first row
Select correct option:
the first row becomes the Last column
the first row becomes the first column
the Last row becomes the first column
the first column becomes the first row
Pointers store the ____________________
Select correct option:
value of a variable
memory address
characters
None of the given
Select correct option:
value of a variable
memory address
characters
None of the given
Which of the following function call is “call by reference” for the following function prototype? int add (int *);
Select correct option:
add(&x);
add(int x);
add(x);
add(*x);
Select correct option:
add(&x);
add(int x);
add(x);
add(*x);
The name of the array is a constant pointer which contains the memory address of the ____________of the array.
Select correct option:
first element
Last element
second element
None of the given
Select correct option:
first element
Last element
second element
None of the given
array name always contains the memory address of the ___________of the array
Select correct option:
entire elements
last element
first element
None of the given
Select correct option:
entire elements
last element
first element
None of the given
At the___________, we try to break up the problem into functional units
Select correct option:
analysis phase
design phase
Implementation phase
None of the given
Select correct option:
analysis phase
design phase
Implementation phase
None of the given
CS201 – Introduction to Programming
Online Quiz # 1
10th May, 2010
Total Questions 10:
Question # 4 of 10 ( Start time: 11:04:08 PM ) Total Marks: 1
Pointers are a special type of __________in which a memory address is stored
Select correct option:
variables (handouts, page # 143)
Location
Characters
None of the given
Question # 5 of 10 ( Start time: 11:04:27 PM ) Total Marks: 1
In C/C++; by default arguments are passed by _______ to a function.
Select correct option:
Reference
Value
Type
Data
(not 100% sure, but I selected option # 2 “Value”, kindly verify it)
Question # 6 of 10 ( Start time: 11:04:50 PM ) Total Marks: 1
Which of the following function call is “call by reference” for the following function prototype? int add (int *);
Select correct option:
add(&x);
add(int x);
add(x);
add(*x);
Question # 7 of 10 ( Start time: 11:05:48 PM ) Total Marks: 1
The ASCHI code of null character is___________
Select correct option:
000 (see page # 113)
010
111
110
Question # 9 of 10 ( Start time: 11:07:46 PM ) Total Marks: 1
_________ Keyword is used to return some value from a function.
Select correct option:
break
return
continue
goto
(I selected option # 2, “return”)
Question # 10 of 10 ( Start time: 11:08:00 PM ) Total Marks: 1
Which of the function call is call by value for the following function prototype? float add(int);
Select correct option:
add(&x);
add(x);
add(int x);
add(*x);