CS201 Objective Mega File-1 PDF
CS201 Objective Mega File-1 PDF
CS201 Objective Mega File-1 PDF
http://vustudents.ning.com
http://vustudents.ning.com
Yes
No
byte
integer
string
http://vustudents.ning.com 1
CS201 Latest Solved MCQs
http://vustudents.ning.com
Quiz Start Time: 09:34 PM
int
short
long
double
http://vustudents.ning.com 2
CS201 Latest Solved MCQs
http://vustudents.ning.com
Quiz Start Time: 09:34 PM Time Left 86
sec(s)
Loader
Debugger
Compiler
Linker
http://vustudents.ning.com 3
CS201 Latest Solved MCQs
http://vustudents.ning.com
Quiz Start Time: 09:34 PM Time Left 79
sec(s)
y[4];
y[3];
y[2];
none of given
long
int
short
double
http://vustudents.ning.com 4
CS201 Latest Solved MCQs
http://vustudents.ning.com
Quiz Start Time: 09:34 PM Time Left 80
sec(s)
values
variables
data
http://vustudents.ning.com 5
CS201 Latest Solved MCQs
http://vustudents.ning.com
► Rectangle
► Arrow symbol
► Oval
► Circle
► Must
► Optional
► Not necessary
► A syntax error
http://vustudents.ning.com 6
CS201 Latest Solved MCQs
http://vustudents.ning.com
Question No: 6 ( Marks: 1 ) - Please choose one
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’;
►4
►5
►6
►7
►3
http://vustudents.ning.com 7
CS201 Latest Solved MCQs
http://vustudents.ning.com
►9
► 12
►2
►*ptr = arr ;
►ptr = arr ;
►*ptr = arr[5] ;
►ptr = arr[5] ;
►True
►False
http://vustudents.ning.com 8
CS201 Latest Solved MCQs
http://vustudents.ning.com
FINALTERM EXAMINATION
Fall 2008
CS201- Introduction to Programming
Time: 120 min
Marks: 75
Question No: 1 ( Marks: 1 ) - Please choose one
► Two
► Three
► Four
► Five
► Different
► Identical
► Two names of same function
► None of the above
http://vustudents.ning.com 9
CS201 Latest Solved MCQs
http://vustudents.ning.com
Question No: 4 ( Marks: 1 ) - Please choose one
► True
► False
► True
► False
► Local
► Global
► Global or static
► None of the given option
The compiler does not provide a copy constructor if we do not provide it……….
//Normally it provides but in some cases of classes it is good practice to provide user
define copy constructor…
► True
► False
http://vustudents.ning.com 10
CS201 Latest Solved MCQs
http://vustudents.ning.com
What is the functionality of the following syntax to delete an array of 5 objects named arr
allocated using new operator?
delete arr ;
What is the sequence of event(s) when allocating memory using new operator?
► True
► False
The operator function of << and >> operators are always the member function of a class.
► True
► False
http://vustudents.ning.com 11
CS201 Latest Solved MCQs
http://vustudents.ning.com
A template function must have at least ---------- generic data type
► Zero
► One
► Two
► Three
► int
► void
► double
► float
Suppose a program contains an array declared as int arr[100]; what will be the size of
array?
►0
► 99
► 100
► 101
► True
► False
► True
► False
http://vustudents.ning.com 12
CS201 Latest Solved MCQs
http://vustudents.ning.com
► 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
► Functions, operators
► Classes, operators
► Operators, functions
► Operators, classes
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
http://vustudents.ning.com 13
CS201 Latest Solved MCQs
http://vustudents.ning.com
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
► at file scope
► within class definition
► within member function
► within main function
► data type
► memory referee
► value
► none of the given options.
► True
► False
http://vustudents.ning.com 14
CS201 Latest Solved MCQs
http://vustudents.ning.com
Question No: 30 ( Marks: 1 ) - Please choose one
Automatic variable are created on ________.
► Heap
► Free store
► static storage
► stack
Current
Compiler is a
► System software
► Application Software
► Driver
► Editor
Operating System is
► An application software
► System Software
► Computer Language
► Interpreter
Which one is the correct syntax for defining an identifier PI with preprocessor directive?
► #define PI 3.1415926;
► #define PI 3.1415926
► #define PI = 3.1415926 ;
► #define PI = 3.1415926
http://vustudents.ning.com 15
CS201 Latest Solved MCQs
http://vustudents.ning.com
Question No: 5 ( Marks: 1 ) - Please choose one
Which of the following is NOT a preprocessor directive?
► #error
► #define
► #line
► #ndefine
► a = (b = (c = (d = (e = 42))));
► (a = b = (c = (d = (e = 42))));
► a = b = (c = (d = (e = 42)));
► (a = b) = (c = d) = (e = 42);
► Member function
► Non-member function
► Private function
► Public function
► True
► False
http://vustudents.ning.com 16
CS201 Latest Solved MCQs
http://vustudents.ning.com
Question No: 10 ( Marks: 1 ) - Please choose one
When we define an array of objects then,
The stream objects cin and cout are included in which header file?
► iostream.h
► fstream.h
► istream.h
► ostream.h
What is the sequence of event(s) when allocating memory using new operator?
► Logical error
► Syntax error
► Runtime error
► None of the given options
► True
► False
http://vustudents.ning.com 17
CS201 Latest Solved MCQs
http://vustudents.ning.com
Question No: 15 ( Marks: 1 ) - Please choose one
► True
► False
What will be the correct syntax for initialization of pointer ptr of type int with variable x?
Which of the following function calling mechanism is true for the function prototype
given below?
float func(float &);
► Call by value
► Call by reference using pointer
► Call by reference using reference variable
► None of the given options
► obj2 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
http://vustudents.ning.com 18
CS201 Latest Solved MCQs
http://vustudents.ning.com
Question No: 19 ( Marks: 1 ) - Please choose one
Which of the following object(s) will call the member operator function within the
statement given below?
obj1=obj2+obj3;
► Object obj1
► Object obj2
► Object obj3
► Any of the object
For cin, the source is normally a ________ and destination can be ______.
The region of memory, available for allocation at run time in C language is called
________ memory whereas in C++ language is called as ________________.
► Heap, Stack
► Stack, Free Store
► Heap, Free Store
► None of above
http://vustudents.ning.com 19
CS201 Latest Solved MCQs
http://vustudents.ning.com
Question No: 24 ( Marks: 1 ) - Please choose one
► Automatic variable
► Global variable
► Functional variable
► None of the given option
When a call to a user-defined function finishes, the variable defined inside the function is
still in existence.
► True
► False
To avoid dangling reference, always return the reference of a local variable from a
function.
► True
► False
► Last
► Middle
► Post Design
http://vustudents.ning.com 20
CS201 Latest Solved MCQs
http://vustudents.ning.com
► First
"delete" operator is used to return memory to free store, which is allocated by the "new"
operator.
► True
► False
In C/C++ if we define an array of size eight (8) i.e. int Arr [8]; then the last element of
this array will be stored at,
► Arr[0]
► Arr[8]
► Arr[7]
► Arr[-1]
When an array is passed to a function then default way of passing this array is,
► By data
► By reference
► By value
► By data type
► Memory addresses
► Variables
► Data Type
► Data
► True
► False
http://vustudents.ning.com 21
CS201 Latest Solved MCQs
http://vustudents.ning.com
Question No: 5 ( Marks: 1 ) - Please choose one
What is the sequence of event(s) when allocating memory using new operator?
We can delete an array of objects without specifying [] brackets if a class is not doing
dynamic memory allocation internally.
► True
► False
The second parameter of operator functions for << and >> are objects of the class for
which we are overloading these operators.
► True
► False
Which of the following is correct way to initialize a variable x of int type with value 10?
► int x ; x = 10 ;
► int x = 10 ;
► int x, x = 10;
► x = 10 ;
http://vustudents.ning.com 22
CS201 Latest Solved MCQs
http://vustudents.ning.com
Question No: 10 ( Marks: 1 ) - Please choose one
Default mechanism of function calling in case of array is _____ and in case of variable is
___. http://vustudents.ning.com
For which array, the size of the array should be one more than the number of elements in
an array?
► int
► double
► float
► char
http://vustudents.ning.com 23
CS201 Latest Solved MCQs
http://vustudents.ning.com
Question No: 14 ( Marks: 1 ) - Please choose one
new and delete are _____ whereas malloc and free are _____.
► Functions, operators
► Classes, operators
► Operators, functions
► Operators, classes
► Member functions
► Public member functions
► Private member functions
► Non-member functions
The prototype of friend functions must be written ____ the class and its definition must
be written ____
► obj2 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
http://vustudents.ning.com 24
CS201 Latest Solved MCQs
http://vustudents.ning.com
Question No: 18 ( Marks: 1 ) - Please choose one
For cin, the source is normally a ________ and destination can be ______.
► Heap
► System Cache
► None of the given options
► Stack
► function prototype
► function definition
► both function prototype or function definition
► none of the given options.
http://vustudents.ning.com 25
CS201 Latest Solved MCQs
http://vustudents.ning.com
Question No: 23 ( Marks: 1 ) - Please choose one
While calling function, the arguments are assigned to the parameters from _____________.
► left to right.
► right to left
► no specific order is followed
► none of the given options.
When an operator function is defined as member function for a binary Plus (+) operator
then the number of argument it take is/are.
► Zero
► One
► Two
► N arguments
With user-defined data type variables (Objects), self assignment can produce
__________.
► Syntax error
► Logical error
► Link error
► Non of the given options
Assignment operator is used to initialize a newly declared object from existing object.
► True
► False
http://vustudents.ning.com 26
CS201 Latest Solved MCQs
http://vustudents.ning.com
Question No: 28 ( Marks: 1 ) - Please choose one
new operator allocates memory from free store and return _____________.
► A pointer
► A reference
► An integer
► A float
http://vustudents.ning.com 27
Almost 300 Solved MCQs of CS201
By
http://vustudents.ning.com
Default constructor takes _________.
one parameter
two parameters
no parameters
character type parameter
$
&
#
_
The members of a class declared with the keyword struct are _____________by default.
static
private
protected
public
We cannot use ______________ pointer for storing and reading data from it.
NULL
integer
double
zero
http://vustudents.ning.com 1
When an object of a class is defined inside another class then,
Copy constructor
Default constructor
Assignment operator
Parameterized constructor
pointers
arrays
references
variables
In statement Matrix m2 = m1 ;
From the following; which on is the correct syntax of an array declaration: array size is 5
and it is of float data type?
http://vustudents.ning.com 2
A structure is a collection of _____________under a single name.
values
variables
data
None of the given
logical error
syntax error
run time error
None of these
When the if statement consists more than one statement 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
_______________function give the position of the next character to be read from that
file.
tellp()
tellg()
seekg()
seekp()
http://vustudents.ning.com 3
Pointers store the ____________________ http://vustudents.ning.com
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
15
18
16
17
ctype.h
iostream.h
string.h
None of the given
____________________ Returns true if c is a digit or a letter and false otherwise.
http://vustudents.ning.com 4
If int sum = 54; Then the value of the following statement is sum = sum - 3 ;
52
50
51
57
referencing operator
dereferencing operator
simple operator
None of the given
Reference
Value
Type
Data
zero
nil
null
one
struc
struct
structure
None of the given
Linux
Unix
Windows
Mac OS
http://vustudents.ning.com 5
http://vustudents.ning.com
analysis phase
design phase
Implementation phase
None of the given
Yes
No
45
6
30
9
Bit-wise OR
Exclusive OR
AND Operator
NOT operator
http://vustudents.ning.com 6
C++ is a_________________ language.
High level
Low level
Machine
Fourth Generation
4
8
6
12
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
http://vustudents.ning.com 7
A character is stored in the memory in _________
byte
integer
string
None of the given
*
+
–
None of the given
______________ transfers the executable code from main 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,
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
http://vustudents.ning.com 8
we have opened a file stream myfile 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
values
variables
data
None of the given
► Underscore
► Digit
► Special character
► Comma
► Single dereferencing
► Single referencing
► Double referencing
► Double dereferencing
http://vustudents.ning.com 9
eof( ), bad( ), good( ), clear( ) all are manipulators.
► True
► False
http://vustudents.ning.com
► True
► False
► True
► False
The default scope for members of structures is public whereas 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
http://vustudents.ning.com 10
How many bytes are occupied by declaring following array of characters?
► 10
► 11
► 12
► 13
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
main(){
int x = 5 ;
int x = 4 ;
http://vustudents.ning.com 11
cout << x << “,” ;
cout << x ;
► 5, 5
► 4, 4
► 4, 5
► 5, 4
Single line comments explaining code would be preceded like in the following example.
► /*
► //
►/
► //*
► switch
► continue
► goto
► break
http://vustudents.ning.com 12
Which of the following will be the correct function call for function prototype given
below?
► 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 _____.
Which of the following operator the compiler overloads for objects by default?
► + operator
► - operator
► = operator
► == operator
http://vustudents.ning.com 13
If overloaded plus operator is implemented as member function then which of the
following option will be true for the statement given below?
► 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
The operator function will be implemented as _____, if both objects (obj1, obj2) are
passed as arguments to - operator in the statement given below.
► friend function
► member function
► non-member function
The input/output streams cin and cout are ________ therefore have _______.
► Structures, function
► Functions, objects
http://vustudents.ning.com 14
What will be the output of following statement?
► 0000128
► 0128128
► 1280000
► 0012800
http://vustudents.ning.com
► shared by objects
Which of the following is used for allocating space for static variables?
► Heap
► Free store
► Stack
http://vustudents.ning.com 15
Templates provide way of abstracting ______________ information.
► type
► data
► method
► access
► Memory Address
► Data values
► protected
► hidden
► private
► public
http://vustudents.ning.com 16
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
http://vustudents.ning.com
► Zero arguments
► logical expressions
► arithmetic expressions
http://vustudents.ning.com 17
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
► 10
► 11
► 12
► 13
► True
► False
http://vustudents.ning.com 18
The prototype of friend functions must be written ____ the class and its definition must
be written ____
► inside, inside 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
1): when we specify the buffer size, normally the 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
http://vustudents.ning.com 19
The declarator of Plus (+) member operator function is
4
8
6
12
http://vustudents.ning.com 20
The reserved words public and private comes under the category
1) :structures
2) :strings
3) :accessibility modifiers
4) :types of functions
► True
► False
► Zero
► One
► Two
► Three
http://vustudents.ning.com 21
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
►0
► 99
► 100
► 101
► True
► False
► True
► False
Which of the following option is true about new operator to dynamically allocate
memory to an object?
http://vustudents.ning.com 22
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
► Non-member functions
► Friend functions
► Any function outside class
► None of the given options
http://vustudents.ning.com 23
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
► at file scope
► within class definition
► within member function
► within main function
► data type
► memory referee
► value
► none of the given options.
http://vustudents.ning.com
► True
► False
http://vustudents.ning.com 24
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
► Decremented only
► Incremented only
► Multiplied only
► Both 1 and 2
► True
► False
Question No: 5 ( Marks: 1 ) - Please choose one
► False
► True
http://vustudents.ning.com 25
What is the functionality of the following statement?
► 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” ;
http://vustudents.ning.com 26
Overloaded member operator function is always called by _______
► Class
► Object
► Compiler
class M {
friend int operator!(const M &);
...
};
► Member function
► Non-member function
http://vustudents.ning.com 27
Copy constructor becomes necessary while dealing with _______allocation in the class.
► Dynamic memory
► Static memory
Small braces
Curly braces
Double quote
Single quote
Zero
One
Two
Three
http://vustudents.ning.com 28
The size of int data type is
► 1 bytes
► 2 bytes
► 3 bytes
► 4 bytes
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
http://vustudents.ning.com 29
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 ►
http://vustudents.ning.com 30
Most efficient method of dealing with structure variables is to define the structure
globally
► True
False ►
Like member functions, ______ can also access the private data members of a class.
Non-member functions
► Friend functions
nested
overloaded
grouped
none of them
http://vustudents.ning.com 31
Come and join us at WebLyceum
For Past Papers, Quiz, Assignments, GDBs, Video Lectures etc
Go to http://www.weblyceum.com and click Register
If we write a statement like s2 = s1; ___ will be the calling object and ____ will be
passed to the = operator as an argument.
► s1, s1
► s1, s2
► s2, s1
► s2, s2
If we write a statement like s2 = s1; s2 will be the calling object and s1 will be
passed to the = operator as an argument. P# 397
► 0000128
► 0128128
► 1280000
► 0012800
default alignment is from left due to this it first prints 4 Zeros(setw=7, digit=3 i.e
1-2-8,) 7-3=4 Zeros vuzs
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
Overloaded new operator function takes parameter of type size_t and returns
► void (nothing)
► void pointer
► object pointer
► int pointer
Also note that the new operator returns a void pointer. Any new operator we write
must have this parameter and return type.
Which of the following is the correct way to declare a variable x of integer type?
► x int ;
► integer x ;
► int x;
► x integer
► Zero
► One
► Two
► Three
The function arguments must contain at least one generic data type. P# 499
We can also define a variable of user define data type (object) as static.
► True
► False
Let suppose
int a, b, c, d, e;
a = b = c = d = e = 42;
This can be interpreted by the complier as:
► a = (b = (c = (d = (e = 42))));
► (a = b = (c = (d = (e = 42))));
► a = b = (c = (d = (e = 42)));
► (a = b) = (c = d) = (e = 42);
a = (b = (c = (d = (e = 42) ) ) );
Which of the following is the correct function call having array named student of
10 elements as a parameter.
► addRecord(student[]) ;
► addRecord(student) ;
► addRecord(student[10]) ;
► addRecord(*student) ;
when we pass array we don’t give limit of array
Example:
Pass array to function
structures do not occupy any memory until it is associated with the structure
variable
An 'Identifier' means any name that the user creates in his/her program. These
names can be of variables, functions and labels
If a class A declares itself a friend of class B and a class B declares itself a friend
of class C then
► Class A is also a friend of class C.
► Class B is also a friend of class A.
► Class A is also a friend of class C if A declares C as its friend.
► Class A is also a friend of class C if C declares A as its friend.
If we want a two-way relationship, OtherClass will have to declare ClassOne as a
friend class, resulting in a complete two-way relationship
When memory for a program is allocated at run time then it is called ________
The truth tables are very important. These are still a tool available for analyzing
logical expressions.
Another member function of cin is getline(). It reads a complete buffer i.e. the
number of character specified up to a delimiter we specify. We can write
something like:
cin.getline(char *buffer, int buff_size, char delimiter = ‘\n’)
( Marks: 1 )
When memory is allocated dynamically using new operator within the
constructor of class then what is an appropriate place to de-allocate the
memory?
(p) ;
It will not delete the p rather, it will send the memory gotten and pointed by p
back to the free store.
( Marks: 2 )
What will be the output of following code, if user input a number 123?
int input ;
cin >> oct >> input;
cout << hex << input ;
( Marks: 2
Calloc function takes two arguments. The first argument is the required space in
terms of numbers while the second one is the size of the space
Now we have to see what happens when either we ask for too much memory at
a time of non-availability of enough memory on the heap or we ask for memory
that is available on the heap , but not available as a single chunk?. In this case,
the call to calloc will fail. When a call to memory allocation functions fails, it
returns a NULL pointer.
( Marks: 3 )
Read the given code and explain code functionality.
( Marks: 3 )
What is the keyword ‘this’ and what are the uses of ‘this’ pointer?
What do you mean by garbage collection and how it works in JAVA and C++ ?
JAVA gives the concept of garbage collection with the use of references. Due to
this garbage collection, we are free from the headache of de- allocating the
memory. We allocate and use the memory. When it is no longer in use, JAVA
automatically deletes (frees) it through garbage collection But in C and C++
languages, we have to take care of de-allocating the memory. In classes where we
use dynamic memory, we have to provide destructors to free this memory. The
languages keep evolving, new constructs will keep evolving in existing or new
languages.
( Marks: 5 )
( Marks: 10 )
Write a simple program using the get() member function of cin object reading a
text of 30 characters from the keyboard, store them in an array and then using
put() member function of cout object to display them on the screen.
( Marks: 10 )
http://www.weblyceum.com
Sometime back we saw an odd behavior in which C++ class data members were not
getting correctly initialized due to memory corruption. It was discovered that this
► malloc
► calloc
► realloc
► free
► #ndefine
list of preprocessors
• #include • #include “filename” • #define • #undef • #ifdef • #ifndef • #if • #else •
#elif • #endif • #error • #line • #pragma • #assert
► True
► False
if we are allocating an array of objects, there is no way to pass arguments to objects’
constructors. Therefore it is required that the objects that are stored in such an array
have a no-argument constructor.
Class templates can have friends. A class or class template, function, or function
template can be a friend to a template class. Friends can also be specializations of a class
template or function template, but not partial specializations.
► 6,8,6
► 6,6,8
► 6,8,8
► 6,6,6
The malloc function differs from calloc in the way that the space allocated by malloc is
not initialized and contains any values initially.
Templates are type-safe. This is because the types that templates act upon are known at
compile time, so the compiler can perform type checking before errors occur.
53
Rational: it will take 123 as octal and print it in hex form which is 53.
Answer:
void String::operator = ( const String &other )
{ int length ;
length = other.length();
delete buf;
buf = new char [length + 1];
strcpy( buf, other.buf );
► Sequential File
► Data File
► Record File
► #error
► #define
► #line
► True
► False
► True
► False
► void (nothing)
► void pointer
► object pointer
► int pointer
The second parameter of operator functions for << and >> are objects of the class
► True
► False
► True
► False
► #include “iostream.h”
► include <iostream.h>
► include <iostream.h>
► #include <iostream.h>
► True
► False
► False
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] ;
What will be the correct syntax to access the value of fourth element of an array
using pointer ptr?
► ptr[3]
► (ptr+3)
► *(ptr+3)
► Both 1and 3
► True
► False
► True
► False
► function prototype
► looped
► nested
► overloaded
► Data encapsulation
► Destructor
► Compile Time
► Run Time
► Link Time
► True
► False
► Class, Objects
► Structures, Pointers
► None of above
► True
► False
Ans:
The manipulators are like something that can be inserted into stream, effecting
a change in the behavior. For example, if we have a floating point number, say
pi (л), and have written it as float pi = 3.1415926 ; Now there is need of
printing the value of pi up to two decimal places i.e. 3.14 . This is a formatting
functionality. For this, we have a manipulator that tells about width and
number of decimal points of a number being printed.
Some manipulators are parameter less. We simply use the name of the
manipulator that works. For example, we have been using endl, which is
actually a manipulator, not data. When we write cout << endl ; a new line is
output besides flushing the buffer. Actually, it manipulates the output stream.
Ans:
1) Matrix m1 (m2); copy constructor
2) Matrix m1, m2;
m1 = m2; assignment operator
3) Matrix m1 = m2; assignment operator
Ans:
1/5
}
ANS:
The errors are in the arguments of the member operation function and also in
the body of operator member function.
Ans:
#include <iostream>
#include <iomanip>
int main ()
{
double x1 = 12345624.72345
double x2 = 987654.12345
double x3 = 1985.23456
cout << setprecision (3) << x1<< endl;
cout << setprecision (4) << x2 << endl;
cout << setprecision (5) << x3<< endl;
return 0;
}
Ans:
Many thing can be possible without using templates but it do offer several
clear advantages not offered by any other techniques:
Advanatages:
• Templates are easier to write than writing several versions of your similar
code for different types. You create only one generic version of your class or
function instead of manually creating specializations.
• Templates are type-safe. This is because the types that templates act upon
are known at compile time, so the compiler can perform type checking before
errors occur.
• Templates can be easier to understand, since they can provide a
straightforward way of abstracting type information.
• It help in utilizing compiler optimizations to the extreme. Then of course
there is room for misuse of the templates. On one hand they provide an
excellent mechanism to create specific type-safe classes from a generic
definition with little overhead.
Disadvantages:
On the other hand, if misused
• Templates can make code difficult to read and follow depending upon
coding style.
• They can present seriously confusing syntactical problems esp. when the
code is large and spread over several header and source files.
• Then, there are times, when templates can "excellently" produce nearly
meaningless compiler errors thus requiring extra care to enforce syntactical
and other design constraints. A common mistake is the angle bracket problem.
#include <iostream.h>
math
{
mth operator + (obj1,obj2)
}
}
……………………………………………………………………………