Admin Admin
Posts : 216 Join date : 2011-06-17 Location : Rawalpindi
| Subject: CS201 Final Term Paper Sat Jun 25, 2011 4:47 pm | |
| -------------------------------------------- CS201 Final Term Paper
Introduction to Programming
FINAL TERM PAPER Spring 2009 CS201- Introduction to Programming
Question No: 1 ( Marks: 1 ) - Please choose one [You must be registered and logged in to see this image.] There are mainly -------------------- types of software ► Two ► Three ► Four ► Five
Question No: 2 ( Marks: 1 ) - Please choose one When x = 7; then the expression x%= 2; will calculate the value of x as, ► 1 ► 3 ► 7 ► 2
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
Question No: 6 ( 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: 7 ( Marks: 1 ) - Please choose one [You must be registered and logged in to see this image.]When we do dynamic memory allocation in the constructor of a class, then it is necessary to provide a destructor. ► True ► False
Question No: 8 ( Marks: 1 ) - Please choose one 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
Question No: 9 ( 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
Question No: 10 ( Marks: 1 ) - Please choose one Deleting an array of objects without specifying [] brackets may lead to memory leak ► True ► False
Question No: 11 ( Marks: 1 ) - Please choose one Which of the following data type will be assumed if no data type is specified with constant? ► short ► float ► int ► double
Question No: 12 ( Marks: 1 ) - Please choose one 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
Question No: 13 ( Marks: 1 ) - Please choose one What will be the correct syntax of the following statement? ptr is a constant pointer to integer. ► const int *ptr ; ► const *int ptr ; ► int const *ptr ; ► int *const ptr ;
Question No: 14 ( Marks: 1 ) - Please choose one Overloaded member operator function is always called by _______ ► Class ► Object ► Compiler ► Primitive data type Question No: 15 ( Marks: 1 ) - Please choose one[You must be registered and logged in to see this image.] Loader loads the executable code from hard disk to main memory. ► True ► False
Question No: 16 ( 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: 17 ( 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: 18 ( 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: 19 ( 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: 20 ( Marks: 1 ) - Please choose one The endl and flush are _______ ► Functions ► Operators ► Manipulators ► Objects
Question No: 21 ( 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: 22 ( 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: 23 ( Marks: 1 ) - Please choose one Classes defined inside other classes are called ________ classes ► looped ► nested ► overloaded ► none of the given options.
Question No: 24 ( 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: 25 ( 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 None of the given options
Question No: 26 ( Marks: 1 ) - Please choose oneWhen the compiler overloads the assignment (=) operator by default then __________ ► compiler does member wise assignment. ► compiler does not allow default overload of assignment (=) operator ► member of the class are not assigned properly ► None of the given options
Question No: 27 ( 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: 28 ( Marks: 1 ) - Please choose oneStatic 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: 29 ( Marks: 1 ) - Please choose oneThe appropriate data type to store the number of rows and colums of the matrix is____________. ► float ► int ► char ► none of the given options.
Question No: 30 ( Marks: 1 ) - Please choose one 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
Question No: 31 ( Marks: 1 )What is drawback of writing the definitions of all the functions before main function?
Question No: 32 ( Marks: 1 ) How do we provide the default values of function parameters?
Question No: 33 ( Marks: 2 ) What is difference between endl and \n?
Question No: 34 ( Marks: 2 ) When does an object get destroyed?
Question No: 35 ( Marks: 3 ) What is the difference between structure and class?
Question No: 36 ( 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: 37 ( Marks: 3 )Why stream insertion and stream extraction operators cannot be overloaded as member functions?
Question No: 38 ( Marks: 5 ) [You must be registered and logged in to see this image.] What is difference between Unary and binary operators and how they can be overloaded?
Question No: 39 ( Marks: 5 ) What steps we must follow to design good program?
Question No: 40 ( Marks: 10 )Write the program that inputs an octalnumber from the user and then display the entered octal number into hexadecimal number using manipulators (parameter-less, parameterized) and member function of input/output streams.
Question No: 41 ( Marks: 10 )Develop a class Vector having two data members; x and y. The class should also provide the following Overloaded operator capabilities. a) Overload the addition operator(+) to add two Vectors b) Overload the assignment operator(=) to assign Resultant Vector c) Write function Display() to display x, y coordinates Note: Addition of vector Let suppose there are two vectors A and B with their x, y coordinates[/size].
| |
|