Education In Pakistan

Papers, Notes, Books & Help For Students

UPDATED EDUCATIONAL NEWS INTERVIEW HELP FOR ALL JOBS ONLINE BOOKS SCHOLARSHIPS AVAILABLE INTERNSHIP JOBS

Tag: Introduction to Programmming

VU CS201 – Introduction to Programmming FinalTerm solved unsolved past papers Spring 2010

VU CS201 – Introduction To Programmming FinalTerm Solved Unsolved Past Papers Spring 2010

FINALTERM  EXAMINATION

Spring 2010

CS201- Introduction to Programming

Ref No: xxxxxxx

Time: 90 min

Marks: 58

Student Info
Student ID: bcxxxxxxxxx
Center: OPKST
Exam Date: 09-08-2001

 

 

For Teacher’s Use Only

Q No.

1

2

3

4

5

6

7

8

Total

Marks

      

      

      

      

      

      

      

      

      

Q No.

9

10

11

12

13

14

15

16

 

Marks

      

      

      

      

      

      

      

      

      

Q No.

17

18

19

20

21

22

23

24

 

Marks

      

      

      

      

      

      

      

      

      

Q No.

25

26

27

28

29

30

31

32

 

Marks

      

      

      

      

      

      

      

      

      

Q No.

33

34

35

36

 

 

 

 

 

Marks

      

      

      

      

      

      

      

      

      

 

 

 

 

 

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

 

 

In if structure the block of statements is executed only,

 

       ► When the condition is false

 

       ► When it contain arithmetic operators

 

       ► When it contain logical operators

 

       ► When the condition is true

 

 

 

Question No: 2      ( Marks: 1 ) – Please choose one

 

 

Header file: fstream.h includes the definition of the stream classes __________.

 

 

       ► ifstream, fstream, cout

 

       ► ifstream, fstream, ofstream

 

       ► fstream, cin, cout

 

       ► None of the above

 

 

 

Question No: 3      ( Marks: 1 ) – Please choose one

 

 

To access the data members of structure _______ is used.

 

       ► dot operator (.)

 

 

       ► * operator

 

 

       ►  operator

 

 

       ► None of given.

 

 

 

 

 

Question No: 4      ( Marks: 1 ) – Please choose one

 

 

eof( ), bad( ), good( ), clear( ) all are manipulators.

 

       ► True

 

       ► False

 

 

 

Question No: 5      ( Marks: 1 ) – Please choose one

 

 

Which kind of functions can access private member variables of a class?

 

 

 

       ► Friend functions of the class

 

       ► Private member functions of the class

 

       ► Public member functions of the class

 

       ► Friend, private and public functions

 

 

 

 

Question No: 6      ( Marks: 1 ) – Please choose one

 

 

The return type of operator function must always be void.

 

 

       ► True

 

       ► False

 

 

 

Question No: 7      ( Marks: 1 ) – Please choose one

 

 

Friend function of a class is ______________ .

 

 

 

       ► Member function

 

 

       ► Non-member function

 

 

       ► Private function

 

 

       ► Public function

 

 

 

Question No: 8      ( Marks: 1 ) – Please choose one

 

 

Function implementation of friend function must be defined outside the class.

 

 

       ► True

 

       ► False

 

 

 

Question No: 9      ( Marks: 1 ) – Please choose one

 

 

The normal source of cin object is,

 

 

       ► File

 

 

       ► Disk

 

 

       ► Keyboard

 

 

       ► RAM

 

 

 

 

 

Question No: 10      ( Marks: 1 ) – Please choose one

 

 

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;

 

 

 

Question No: 11      ( Marks: 1 ) – Please choose one

 

 

Consider the following code segment. What will be the output of the following program?

 

int func(int) ;

int num = 10 ;

 

int main(){

int num ;

num = 5 ;

cout << num ;

cout << func(num) ;

}

int func(int x){

return num ;

}

 

 

       ► 5, 5

 

 

       ► 10, 5

 

 

       ► 5, 10

 

 

       ► 10, 10

 

 

 

 

Question No: 12      ( Marks: 1 ) – Please choose one

 

 

With template function, the compiler automatically detects the passed data and generates a new copy of function using passed data.

 

 

       ► True

 

       ► False

 

 

 

Question No: 13      ( Marks: 1 ) – Please choose one

 

 

What will be the correct syntax to declare two-dimensional array of float data type?

 

 

       ► float arr{2}{2} ;

 

 

 

       ► float arr[2][2] ;

 

 

 

       ► float arr[2,2] ;

 

 

 

       ► float[2][2] arr ;

 

 

 

 

Question No: 14      ( Marks: 1 ) – Please choose one

 

 

The first parameter of operator function for << operator,

 

 

 

 

       ► Must be passed by value

 

       ► Must be passed by reference

 

       ► Can be passed by value or reference

 

       ► Must be object of class

 

 

 

Question No: 15      ( Marks: 1 ) – Please choose one

 

 

Heap is constantly changing in size.

 

       ► True

 

       ► False

 

 

 

Question No: 16      ( 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.

 

 

 

Question No: 17      ( Marks: 1 ) – Please choose one

 

 

Classes defined inside other classes are called ________ classes

 

       ► looped

 

       ► nested

 

       ► overloaded

 

       ► none of the given options.

 

 

 

Question No: 18      ( Marks: 1 ) – Please choose one

 

 

If we define an identifier with the statement #define PI 3.1415926 then during the execution of the program the value of PI __________.

 

 

 

       ► can not be replaced

 

 

       ► None of the given options

 

 

       ► Remain constant.

 

 

       ► can be changed by some operation

 

 

 

Question No: 19      ( 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: 20      ( Marks: 1 ) – Please choose one

 

 

Every class contains _______________.

 

 

 

       ► Constructor

 

 

       ► Destructor

 

 

       ► Both a constructor and a destructor

 

 

       ► None of the given options

 

 

 

 

Question No: 21      ( Marks: 1 ) – Please choose one

 

 

A template function must have

 

 

       ► One or more than one arguments

 

 

       ► Only one argument

 

 

       ► Zero arguments

 

 

       ► None of the given options

 

 

 

Question No: 22      ( Marks: 1 ) – Please choose one

 

 

Structured Query Language is used for ______________

 

       ► Databases Management

 

       ► Networks

 

       ► Writing Operating System

 

       ► none of the given options

 

 

 

Question No: 23      ( Marks: 1 ) – Please choose one

 

 

When a call to a user-defined function finishes, the variable defined inside the function is still in existence.

 

 

       ► True

 

       ► False

 

 

 

Question No: 24      ( Marks: 1 ) – Please choose one

 

 

The precedence of an operator can be changed through operator overloading.

 

       ► True

 

       ► False

 

 

 

Question No: 25      ( Marks: 1 ) – Please choose one

 

 

A Matrix can be composed of ints, floats or doubles as their elements. Best way is to handle this , _______________

 

       ► Write a separate class to handle each

 

 

       ► Use templates

 

       ► Use strings to store all types

 

       ► None of the given options

 

 

 

Question No: 26      ( Marks: 1 ) – Please choose one

 

 

“delete” operator is used to return memory to free store, which is allocated by the “new” operator.

 

 

       ► True

 

       ► False

 

 

 

Question No: 27      ( Marks: 2 )

 

 

What is the difference between switch statement and if statement.

 

 

 

Question No: 28      ( Marks: 2 )

 

 

How can we initialize data members of contained object at construction time?

 

 

Question No: 29      ( Marks: 2 )

 

 

How the data members of a class are initialized with meaningful values?

 

 

 

Question No: 30      ( Marks: 2 )

 

 

Can we overload new and delete operators?

 

 

Question No: 31      ( Marks: 3 )

 

 

What will be the output of following functions if we call these functions three times?

 

1)

void func1(){

int x = 0;

x++;

cout << x << endl;

}

2)

void func2(){

static int x = 0 ;

x++;

cout << x << endl ;

}

 

Question No: 32      ( Marks: 3 )

 

 

What is the keyword ‘this’ and what are the uses of ‘this’ pointer?

 

 

Question No: 33      ( Marks: 3 )

 

 

Suppose an object of class A is declared as data member of class B.

 

(i) The constructor of which class will be called first?

 

(ii) The destructor of which class will be called first?

 

Question No: 34      ( Marks: 5 )

 

 

Write the general syntax of a class that has one function as a friend of a class along with definition of friend function.

 

Question No: 35      ( Marks: 5 )

 

Write down the disadvantages of the templates.

 

Question No: 36      ( Marks: 5 )

 

 

Write a program which defines five variables which store the salaries of five employees, using setw and setfill manipulators to display all these salaries in a column.

 

Note: Display all data with in a particular width and the empty space should be filled with character x

Output should be displayed as given below:

xxxxxx1000

xxxxxx1500

xxxxx20000

xxxxx30000

xxxxx60000

 

 

VU CS201 – Introduction To Programmming FinalTerm Solved Unsolved Past Papers Spring 2010

VU CS201 – Introduction to Programmming FinalTerm solved unsolved past papers Spring 2010

VU CS201 – Introduction To Programmming FinalTerm Solved Unsolved Past Papers Spring 2010

FINALTERM  EXAMINATION

Spring 2010

CS201- Introduction to Programming

Ref No: 1557656

Time: 90 min

Marks: 58

Student Info
Student ID: Dc100200028
Center: OPKST
Exam Date: 12/8/10

 

 

For Teacher’s Use Only

Q No.

1

2

3

4

5

6

7

8

Total

Marks

      

      

      

      

      

      

      

      

      

Q No.

9

10

11

12

13

14

15

16

 

Marks

      

      

      

      

      

      

      

      

      

Q No.

17

18

19

20

21

22

23

24

 

Marks

      

      

      

      

      

      

      

      

      

Q No.

25

26

27

28

29

30

31

32

 

Marks

      

      

      

      

      

      

      

      

      

Q No.

33

34

35

36

 

 

 

 

 

Marks

      

      

      

      

      

      

      

      

      

 

 

 

 

 

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

 

 

Pointer is a variable which store,

 

       ► Data

 

       ► Memory Address

 

       ► Data Type

 

       ► Values

 

 

 

Question No: 2      ( Marks: 1 ) – Please choose one

 

 

All preprocessor directives are started with the symbol______.

 

       ► *

 

       ► +
+

 

       ► @

 

       #

 

 

 

Question No: 3    http://vustudents.ning.com  ( Marks: 1 ) – Please choose one

 

 

Within the statement obj1=obj2;   obj1 will call the assignment operator function and obj2 will be passed as an argument to function.

 

 

       True

 

       ► False

 

 

 

Question No: 4      ( 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: 5      ( Marks: 1 ) – Please choose one

 

 

The second parameter of operator functions for << and >> are objects of the class for which we are overloading these operators. http://vustudents.ning.com

 

 

 

       True

 

       ► False

 

 

 

Question No: 6      ( Marks: 1 ) – Please choose one

 

 

To include code from the library in the program, such as iostream, a directive would be called up using this command.

 

       ► #include “iostream.h”

 

       ► include <iostream.h>

 

       ► include <iostream.h>

 

       #include <iostream.h>

 

 

 

Question No: 7     http://vustudents.ning.com ( Marks: 1 ) – Please choose one

 

 

The number 544.53 must be stored in _____ data type.

 

 

       int

 

       ► short

 

       float

 

       ► char

 

 

 

Question No: 8      ( Marks: 1 ) – Please choose one

 

 

A template function can have different type of arguments.

 

       True

 

       ► False

 

 

 

Question No: 9      ( Marks: 1 ) – Please choose one

 

 

For which values of the integer _value will the following code becomes an infinite loop?

 

int number=1;

while (true) {

cout << number;

if (number == 3) break;

number +=  integer_value; }

 

 

 

     

 any number other than 1 or 2

 

       only 0

 

       ► only 1

 

       ► only 2

 

 

 

Question No: 10      ( Marks: 1 ) – Please choose one

 

 

Template class cannot have static variables. http://vustudents.ning.com

 

       ► True

 

       False

 

 

 

Question No: 11      ( Marks: 1 ) – Please choose one

 

 

Which of the following is used with bit manipulation?

 

 

       Signed integer

 

       ► Un-signed integer

 

       ► Signed double

 

       ► Un-signed double

 

 

 

Question No: 12      ( Marks: 1 ) – Please choose one

 

 

Structure is a collection of ______________ under a single name.

 

 

       ► Only Functions

 

       Only Variables

 

 

       ► Both Functions and Variables

 

       ► None of the given options

 

 

 

 

 

 

 

Question No: 13      ( 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: 14      ( Marks: 1 ) – Please choose one

 

 

Unary operator implemented as member function takes ____ arguments whereas non-member function takes _____ arguments.

 

 

 

 

 

 

 

       ► One, zero

 

       ► Zero, one

 

       ► One, two

 

       ► Two, one

 

 

 

Question No: 15      ( Marks: 1 ) – Please choose one

 

 

The first parameter of overloaded stream insertion operator is _________ where second parameter is _______ http://vustudents.ning.com

 

 

 

       ► input stream, object of class

 

       ► object of class, output stream

 

       output stream, object of class

 

       ► object of class, input stream

 

 

 

Question No: 16      ( Marks: 1 ) – Please choose one

 

 

We can also do conditional compilation with preprocessor directives.

 

       True

 

       ► False

 

 

 

Question No: 17      ( Marks: 1 ) – Please choose one

 

 

If a symbolic constant has been defined, it will be an error to define it again.

 

       ► True

 

       False

 

 

 

Question No: 18      ( 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.

 

 

 

Question No: 19      ( Marks: 1 ) – Please choose one

 

 

Classes defined inside other classes are called ________ classes

 

       ► looped

 

       ► nested

 

       ► overloaded

 

       ► none of the given options.

 

 

 

Question No: 20      ( Marks: 1 ) – Please choose one

 

 

If we define an identifier with the statement #define PI 3.1415926 then during the execution of the program the value of PI __________.

 

 

 

       ► cannot be replaced

 

 

       None of the given options

 

 

       ► Remain constant.

 

 

       ► can be changed by some operation

 

 

 

Question No: 21      ( Marks: 1 ) – Please choose one

 

 

Assignment operator is ————————-associative. http://vustudents.ning.com

 

 

 

       ► right

 

 

       left

 

 

       ► binary

 

 

       ► unary

 

 

 

 

Question No: 22      ( 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: 23      ( Marks: 1 ) – Please choose one

 

 

The return type of the operator function for << operator is __________.

 

 

       ► class for which we overload operator

 

       ► reference of ostream class (ostream&)

 

 

       ► reference of istream class (istream&)

 

 

       ► void

 

 

 

Question No: 24      ( Marks: 1 ) – Please choose one

 

 

The code is written to __________ the program.

 

       ► implement

 

       ► design

 

       ► analysis

 

       ► none of the given options.

 

 

 

Question No: 25      ( Marks: 1 ) – Please choose one

 

 

 

Memory allocated at run time is a system resource and it is the responsibility of _____ to de-allocate the memory. http://vustudents.ning.com

 

 

 

 

 

 

 

       ► System

 

       ► Programmer

 

       ► User of program

 

       ► None of given options

 

 

 

Question No: 26      ( Marks: 1 ) – Please choose one

 

 

Templates are not type safe.

 

       ► true

 

       false

 

 

 

Question No: 27      ( Marks: 2 )

 

 

Give the general syntax of class template.

 

Answer:

Syntax of class template:

 

template <class T>

class class-name()

{

definition of class

};

 

 

 

 

Question No: 28      ( Marks: 2 )

 

 

What is difference between endl and \n?

 

Answer:

The difference between endl and  \n is that endl  is use to start a new line for the next row

And \n is a new line character.

 

 

 

Question No: 29      ( Marks: 2 )

 

 

What is the this pointer? Give an example of its use.

 

Answer:

This pointer is use to points to the current object in programming.

 

Question No: 30      ( Marks: 2 )

 

 

Identify each of the following as function call, function definition and function declaration.

  1. int func(int num1, int num2);

Function call:

Function ; Function definition: Integer; Function declaration: Num1

and Num2

 

 

  1. int func(int, int);

Function call:

Function ; Function definition: Integer; Function declaration: integers

 

  1. func(5, 6) ;

Function call:

Function ; Function definition: numbers; Function declaration: 5&6

 

 

  1. int func(int num1, int num2){}

Function call:

Function ; Function definition: Integer; Function declaration: Num1 and Num2 from

user

 

 

Question No: 31      ( Marks: 3 )

 

 

Consider the following code segment. What will be the output of the following code segment?

 

class class1{

public:

class class2{

public:

class2(){

cout << “Calling default constructor of class2\n” ;

}

};

class1(){

cout << “Calling default constructor of class1\n” ;

}

} ;

main(){

class1::class2 obj1;

class1 obj2 ;

}

 

 

 

 

Question No: 32      ( Marks: 3 )

 

 

Is it possible to define two functions as given below? Justify your answer.

func(int x, int y)

func(int &x, int &y)

 

Answer:

No, we cannot define two functions as func(intx, inty) func(int &x, int&y) because it’s give an error function not initializing.

 

Question No: 33      ( Marks: 3 )

 

 

What happens when we use new and delete operator?

 

Answer:

When we use new operator to create objects the memory space is allocated for the object and then its constructor is called. Similarly, when we use delete operator with our objects, the destructor is called for the object before deallocating the storage to the object.

 

 

 

 

 

 

Question No: 34      ( Marks: 5 )

 

 

What is the difference between function overloading and operator overloading?

 

Answer:

Difference b/w function overloading and operator overloading is:

 

In function overloading, the functions have the same name but differ either by the number of arguments or the type of the arguments.

 

Operator overloading is to allow the same operator to be bound to more than one implementation, depending on the types of the operands.

 

 

 

 

Question No: 35      ( Marks: 5 )

 

 

Why the first parameter of operator function for << operator must be passed by reference?

 

Answer:

Operator<<‘s first parameter must be an ostream passed by reference. Its second parameter, the IntList that is printed, does not have to be passed as a const-reference parameter; however it is more efficient to pass it by reference than by value (since that avoids a call to the copy constructor), and it should not be modified by operator<<, so it should be a const reference parameter

 

 

Question No: 36      ( Marks: 5 )

 

 

Read the given below code and explain what task is being performed by this function

 

Matrix :: Matrix ( int row , int col )

{

numRows = row ;

numCols = col ;

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 ] = 0.0 ;

}

}

 

 

 

Hint : This function belong to a matrix class, having

Number of Rows = numRows

Number of Columns = numCols

 

Answer:

In this code the matrix function is defined, it get the number of rows from the user and create the row of matrix and then get the columns from the user and create the columns. The New is showing for creating more array space for the data which user enters. The elements [i][j] will print the data in matrix form. http://vustudents.ning.com

VU CS201 – Introduction To Programmming FinalTerm Solved Unsolved Past Papers Spring 2010

VU CS201 – Introduction to Programmming FinalTerm solved unsolved past papers Spring 2010

VU CS201 – Introduction To Programmming FinalTerm Solved Unsolved Past Papers Spring 2010

FINALTERM  EXAMINATION

Spring 2010

CS201- Introduction to Programming

Ref No: xxxxxxx

Time: 90 min

Marks: 58

Student Info
Student ID: bcxxxxxxxxx
Center: OPKST
Exam Date: 09-08-2001

 

 

For Teacher’s Use Only

Q No.

1

2

3

4

5

6

7

8

Total

Marks

      

      

      

      

      

      

      

      

      

Q No.

9

10

11

12

13

14

15

16

 

Marks

      

      

      

      

      

      

      

      

      

Q No.

17

18

19

20

21

22

23

24

 

Marks

      

      

      

      

      

      

      

      

      

Q No.

25

26

27

28

29

30

31

32

 

Marks

      

      

      

      

      

      

      

      

      

Q No.

33

34

35

36

 

 

 

 

 

Marks

      

      

      

      

      

      

      

      

      

 

 

 

 

 

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

 

 

In if structure the block of statements is executed only,

 

       ► When the condition is false

 

       ► When it contain arithmetic operators

 

       ► When it contain logical operators

 

       ► When the condition is true

 

 

 

Question No: 2      ( Marks: 1 ) – Please choose one

 

 

Header file: fstream.h includes the definition of the stream classes __________.

 

 

       ► ifstream, fstream, cout

 

       ► ifstream, fstream, ofstream

 

       ► fstream, cin, cout

 

       ► None of the above

 

 

 

Question No: 3      ( Marks: 1 ) – Please choose one

 

 

To access the data members of structure _______ is used.

 

       ► dot operator (.)

 

 

       ► * operator

 

 

       ►  operator

 

 

       ► None of given.

 

 

 

 

 

Question No: 4   http://vustudents.ning.com   ( Marks: 1 ) – Please choose one

 

 

eof( ), bad( ), good( ), clear( ) all are manipulators.

 

       ► True

 

       ► False

 

 

 

Question No: 5      ( Marks: 1 ) – Please choose one

 

 

Which kind of functions can access private member variables of a class?

 

 

 

       ► Friend functions of the class

 

       ► Private member functions of the class

 

       ► Public member functions of the class

 

       ► Friend, private and public functions

 

 

 

 

Question No: 6      ( Marks: 1 ) – Please choose one

 

 

The return type of operator function must always be void.

 

 

       ► True

 

       ► False

 

 

 

Question No: 7      ( Marks: 1 ) – Please choose one

 

 

Friend function of a class is ______________ .

 

 

 

       ► Member function

 

 

       ► Non-member function

 

 

       ► Private function

 

 

       ► Public function

 

 

 

Question No: 8      ( Marks: 1 ) – Please choose one

 

 

Function implementation of friend function must be defined outside the class.

 

 

       ► True

 

       ► False

 

 

 

Question No: 9      ( Marks: 1 ) http://vustudents.ning.com– Please choose one

 

 

The normal source of cin object is,

 

 

       ► File

 

 

       ► Disk

 

 

       ► Keyboard

 

 

       ► RAM

 

 

 

 

 

Question No: 10      ( Marks: 1 ) – Please choose one

 

 

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;

 

 

 

Question No: 11      ( Marks: 1 ) – Please choose one

 

 

Consider the following code segment. What will be the output of the following program?

 

int func(int) ;

int num = 10 ;

 

int main(){

int num ;

num = 5 ;

cout << num ;

cout << func(num) ;

}

int func(int x){

return num ;

}

 

 

       ► 5, 5

 

 

       ► 10, 5

 

 

       ► 5, 10

 

 

       ► 10, 10

 

 

 

 

Question No: 12      ( Marks: 1 ) –http://vustudents.ning.com Please choose one

 

 

With template function, the compiler automatically detects the passed data and generates a new copy of function using passed data.

 

 

       ► True

 

       ► False

 

 

 

Question No: 13      ( Marks: 1 ) – Please choose one

 

 

What will be the correct syntax to declare two-dimensional array of float data type?

 

 

       ► float arr{2}{2} ;

 

 

 

       ► float arr[2][2] ;

 

 

 

       ► float arr[2,2] ;

 

 

 

       ► float[2][2] arr ;

 

 

 

 

Question No: 14      ( Marks: 1 ) – Please choose one

 

 

The first parameter of operator function for << operator,

 

 

 

 

       ► Must be passed by value

 

       ► Must be passed by reference

 

       ► Can be passed by value or reference

 

       ► Must be object of class

 

 

 

Question No: 15      ( Marks: 1 ) – Please choose one

 

 

Heap is constantly changing in size.

 

       ► True

 

       ► False

 

 

 

Question No: 16      ( 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.

 

 

 

Question No: 17      ( Marks: 1 ) http://vustudents.ning.com – Please choose one

 

 

Classes defined inside other classes are called ________ classes

 

       ► looped

 

       ► nested

 

       ► overloaded

 

       ► none of the given options.

 

 

 

Question No: 18      ( Marks: 1 ) – Please choose one

 

 

If we define an identifier with the statement #define PI 3.1415926 then during the execution of the program the value of PI __________.

 

 

 

       ► can not be replaced

 

 

       ► None of the given options

 

 

       ► Remain constant.

 

 

       ► can be changed by some operation

 

 

 

Question No: 19      ( 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: 20      ( Marks: 1 ) http://vustudents.ning.com– Please choose one

 

 

Every class contains _______________.

 

 

 

       ► Constructor

 

 

       ► Destructor

 

 

       ► Both a constructor and a destructor

 

 

       ► None of the given options

 

 

 

 

Question No: 21      ( Marks: 1 ) – Please choose one

 

 

A template function must have

 

 

       ► One or more than one arguments

 

 

       ► Only one argument

 

 

       ► Zero arguments

 

 

       ► None of the given options

 

 

 

Question No: 22      ( Marks: 1 ) – Please choose one

 

 

Structured Query Language is used for ______________http://vustudents.ning.com

 

       ► Databases Management

 

       ► Networks

 

       ► Writing Operating System

 

       ► none of the given options

 

 

 

Question No: 23      ( Marks: 1 ) – Please choose one

 

 

When a call to a user-defined function finishes, the variable defined inside the function is still in existence.

 

 

       ► True

 

       ► False

 

 

 

Question No: 24      ( Marks: 1 ) – Please choose one

 

 

The precedence of an operator can be changed through operator overloading.

 

       ► True

 

       ► False

 

 

 

Question No: 25      ( Marks: 1 ) – Please choose one

 

 

A Matrix can be composed of ints, floats or doubles as their elements. Best way is to handle this , _______________ http://vustudents.ning.com

 

       ► Write a separate class to handle each

 

 

       ► Use templates

 

       ► Use strings to store all types

 

       ► None of the given options

 

 

 

Question No: 26      ( Marks: 1 ) – Please choose one

 

 

“delete” operator is used to return memory to free store, which is allocated by the “new” operator.

 

 

       ► True

 

       ► False

 

 

 

Question No: 27      ( Marks: 2 )

 

 

What is the difference between switch statement and if statement.

 

 

 

Question No: 28      ( Marks: 2 )

 

 

How can we initialize data members of contained object at construction time?

 

 

Question No: 29      ( Marks: 2 )

 

 

How the data members of a class are initialized with meaningful values?

 

 

 

Question No: 30      ( Marks: 2 )

 

 

Can we overload new and delete operators?

 

 

Question No: 31      ( Marks: 3 )

 

 

What will be the output of following functions if we call these functions three times?

 

1)

void func1(){

int x = 0;

x++;

cout << x << endl;

}

2)

void func2(){

static int x = 0 ;

x++;

cout << x << endl ;

}

 

Question No: 32      ( Marks: 3 )

 

 

What is the keyword ‘this’ and what are the uses of ‘this’ pointer?

 

 

Question No: 33      ( Marks: 3 )

 

 

Suppose an object of class A is declared as data member of class B.

 

(i) The constructor of which class will be called first?

 

(ii) The destructor of which class will be called first?

 

Question No: 34      ( Marks: 5 )

 

 

Write the general syntax of a class that has one function as a friend of a class along with definition of friend function.

 

Question No: 35      ( Marks: 5 )

 

Write down the disadvantages of the templates. http://vustudents.ning.com

 

Question No: 36      ( Marks: 5 )

 

 

Write a program which defines five variables which store the salaries of five employees, using setw and setfill manipulators to display all these salaries in a column.

 

Note: Display all data with in a particular width and the empty space should be filled with character x

Output should be displayed as given below:

xxxxxx1000

xxxxxx1500

xxxxx20000

xxxxx30000

xxxxx60000

 

 

VU CS201 – Introduction To Programmming FinalTerm Solved Unsolved Past Papers Spring 2010

Education In Pakistan © 2016