FINALTERM EXAMINATION
Fall 2009
CS201- Introduction to Programming
Time: 120 min
Marks: 75
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
What will be the output of following statement?
cout << setfill(‘0’) << setw(7) << 128 ;
► 0000128
► 0128128
► 1280000
► 0012800
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
Constructors can not be overloaded like ordinary functions.
► True
► False
Overloaded new operator function takes parameter of type size_t and returns
► void (nothing)
► void pointer
► object pointer
► int pointer
Which of the following is the correct way to declare a variable x of integer type?
► x int ;
► integer x ;
► int x;
► x integer
Reserve words cannot be used as a variable name.
► True
► False
A template function must have at least ---------- generic data type
► Zero
► One
► Two
► Three
Template functions can also be overloaded
► True
► False
We can not make a member function of a class as template function.
► True
► False
When break statement is encountered in switch statement, it
► Stops the entire program
► Stops the execution of current statement
► Exits from switch statement
► None of the given options
We can also define a variable of user define data type (object) as static.
► True
► False
The declarator of Plus (+) member operator function is
► Class-Name operator + (Class-Name rhs)
► operator Class-Name + ( )
► operator Class-Name + ( rhs)
► Class-Name operator + ( )
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);
What will be the range of numbers generated by function rand () % 9?
► 0 to 9
► 1 to 9
► 0 to 8
► 1 to 8
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) ;
Declaring structures does not mean that memory is allocated.
► True
► False
Identifier is a name that can be given to variables, labels and functions.
► True
► False
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.
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.
A pointer is a special type of variable that contain ___________
► Memory Address
► Data values
► Both Values and Memory
► None of given of options
When memory for a program is allocated at run time then it is called ________
► static memory allocation
► dynamic memory allocation
► stack memory allocation
► virtual memory allocation
What purpose do classes serve?
► Data encapsulation
► Providing a convenient way of modeling real-world objects
► Simplifying code reuse
► All of the given options
Which of the following function cannot be overloaded?
► Member functions
► Utility functions
► Constructor
► Destructor
The following prototype of unary operator function indicates that it is ____________ .
Date operator++(int )
► Member functions of post increment operator
► Member functions of pre increment operator
► Non-member functions of post increment operator
► Non-member functions of pre increment operator
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
In the member initializer list, the data members are initialized,
► From left to right
► From right to left
► In the order in which they are defined within class
► None of the given options
If we do not indent the code properly it will __________________
► Be a syntax error
► Be a logical error
► Not be an error at all
► None of the given options
Truth tables are used for analyzing ___________.
► logical expressions
► arithmetic expressions
► both logical and arithmetic expressions
► none of the given options.
Static memory allocation is also known as ____________
► Dynamic allocation
► Compile time allocation
► Run time allocation
► None of the given options
( Marks: 1 )
What does getline() member function of cin stream do?
( 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?
( 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
What is memory leak?
( Marks: 3 )
When we call calloc function to allocate memory and its return a NULL pointer what does it mean?
( Marks: 3 )
Read the given code and explain code functionality.
Matrix :: Matrix ( const Matrix & m )
{
numRows = m.numRows ;
numCols = m.numCols ;
elements = new ( double * ) [ numRows ] ;
for ( int i = 0 ; i < numRows ; i ++ )
{
elements [ i ] = new double [ numCols ] ;
for ( int j = 0 ; j < numCols ; j ++ )
elements [ i ] [ j ] = m.elements [ i ] [ j ] ;
}
}
( Marks: 3 )
What is the keyword ‘this’ and what are the uses of ‘this’ pointer?
( Marks: 5 )
What do you mean by garbage collection and how it works in JAVA and C++ ?
( Marks: 5 )
Explain the concept of separation of interface from the implementation in the context of classes, using a real world example.
( 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 )
Overload the Binary Assignment (=) Operator.
Write a program which has a class List, This class should have Two data members, an array of integers list[] and an integer variable length (i.e. number of elements in the list).The class should further contain a default constructor, a Print() function which display the list and a Function insert() which insert an element in the list and Assignment (= ) Operator function, which contain code for the assignment of one object to other. .
In main function define two objects list1 and list2 and use the statement list2 = list1; and use (call ) print function with both objects
No comments:
Post a Comment