Paper Tayyari

Final Term PreparationFinal term ki tayyari

Syllabus: lectures 25–45. Past-paper MCQs are shown first.Syllabus: lecture 25–45. Past paper ki MCQs pehle dikhai gayi hain.

207 MCQs · 55 short · 32 long questions · 207 MCQs from past papers207 MCQs · 55 short · 32 long sawal · 207 MCQs past papers se

Start mock testMock test shuru karein
DoneHal kiye 0/207
– correctsahi
1.
★ Past paper collectionLecture 26

An instance of a class is called __________.

  1. Astructure
  2. Bdata type
  3. Cobject
  4. Dmember function

An object is a variable (instance) created from a class.

2.
★ Final term 2017 (paper 1)Lecture 29

If a friend function outside the class declares itself friend of the class, this may violate the concept of ________.

  1. AEncapsulation and data accessing
  2. BEncapsulation and data hiding
  3. CFriend member functions of the class
  4. DInterface of the class

Friendship must be granted by the class; a function granting itself access would break encapsulation and data hiding.

3.
★ Final term 2017 (paper 1)Lecture 29

The prototype of friend function is written ________.

  1. ABefore the class definition
  2. BAs private member function
  3. CAnywhere inside the class definition
  4. DIn the main function

A friend declaration can appear anywhere in the class; access specifiers do not affect it.

4.
★ Final term 2017 (paper 2)Lecture 29

Friend class of the other class gets ______ access to ______.

  1. APartial, data member and member functions.
  2. BRead only, data member and member functions.
  3. CComplete, data members only.
  4. DComplete, all data members and member functions.

A friend class can access all private and protected members of the class that befriends it.

5.
★ Final term solved MCQs (Moaaz & Asad)Lecture 29

Which of the following statement is best regarding declaration of friend function?

  1. AFriend function must be declared after public keyword.
  2. BFriend function must be declared after private keyword.
  3. CFriend function must be declared at the top within class definition.
  4. DIt can be declared anywhere in class as these are not affected by the public and private keywords.

Access specifiers do not affect friend declarations, so they may appear anywhere in the class.

6.
★ Final term solved MCQs (Moaaz & Asad)Lecture 29

Like member functions, ______ can also access the private data members of a class.

  1. ANon-member functions
  2. BFriend functions
  3. CAny function outside class
  4. DNone of the given options

A friend function is granted access to the class's private members.

7.
★ Final term solved MCQs (Moaaz & Asad)Lecture 29

Friend function of a class is ______________ .

  1. AMember function
  2. BNon-member function
  3. CPrivate function
  4. DPublic function

A friend function is not a member of the class even though it has access to it.

8.
★ Final term solved MCQs (Moaaz & Asad)Lecture 29

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

  1. ATrue
  2. BFalse

A friend function can also be defined inline inside the class body.

9.
★ Final term solved MCQs (Moaaz & Asad)Lecture 29

The prototype of friend functions must be written ____ the class and its definition must be written ____

  1. Ainside, inside the class
  2. Binside, outside the class
  3. Coutside, inside the class
  4. Doutside, outside the class

The friend declaration goes inside the class and the function is normally defined outside it.

10.
★ Final term solved MCQs (Moaaz & Asad)Lecture 29

A function can declare itself a friend of a class.

  1. ATrue
  2. BFalse

Friendship is granted by the class, not claimed by the function.

11.
★ Final term Fall 2005Lecture 29

A friend function of a class has access

  1. ATo all data member and functions of the class
  2. BOnly to other friend functions of the class
  3. COnly to private data of the class
  4. DOnly to public data of the class

A friend can use all members of the class, including private and protected ones.

12.
★ Final term Spring 2005Lecture 29

A friend function

  1. Amust be having a prototype with no arguments
  2. Bmust be invoked by the class that declares it a friend
  3. Cmust be invoked by an object of the class that declares it a friend
  4. Dcan access the private data of the class that declares it a friend

A friend is not a member but is allowed to use the class's private data.

13.
★ Final term 2017 (paper 2)Lecture 30

A ______ is considered as a special type of pointer which contains address of a memory location.

  1. AFunction
  2. BStructure
  3. CReference
  4. DClass

A reference is an alias implemented like a constant pointer that is automatically dereferenced.

14.
★ Final term 2017 (paper 4)Lecture 30

Which of the following will be the correct function call for function prototype given below? int func (int &);

  1. Afunc(int num);
  2. Bfunc(&num);
  3. Cfunc(num);
  4. Dfunc(*num);

A reference parameter is passed the variable itself, so the call is func(num); &num would pass an int* and not compile.

15.
★ Final term solved MCQs (Moaaz & Asad)Lecture 30

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 _____.

  1. AAddress of variable, reference variable
  2. BReference variable, value of variable
  3. CReference variable, address of variable
  4. DAddress of variable, value of variable

In a declaration (int &r) & makes a reference; in an expression (&x) it takes the address.

16.
★ Final term solved MCQs (Moaaz & Asad)Lecture 30

We can do arithmetic with references like pointers.

  1. ATrue
  2. BFalse

A reference is an alias; arithmetic on it changes the referred value, not an address.

17.
★ Final term solved MCQs (Moaaz & Asad)Lecture 30

Which of the following function calling mechanism is true for the function prototype given below? float func(float &);

  1. ACall by value
  2. BCall by reference using pointer
  3. CCall by reference using reference variable
  4. DNone of the given options

float & declares a reference parameter.

18.
★ Final term solved MCQs (Moaaz & Asad)Lecture 30

In functions that return reference, use __________variables.

  1. ALocal
  2. BGlobal
  3. CGlobal or static
  4. DNone of the given option

Returning a reference to a local would dangle; global or static variables outlive the call.

19.
★ Solved MCQs collectionLecture 30

To avoid dangling reference, always return the reference of a local variable from a function.

  1. ATrue
  2. BFalse

Returning a reference to a local variable creates a dangling reference.

20.
★ Past paper collectionLecture 30

We cannot increment ____________.

  1. Apointers
  2. Barrays
  3. Creferences
  4. Dvariables

A reference is a fixed alias; ++ on it changes the referred variable, not the reference itself.

21.
★ Past paper collectionLecture 30

We can _____________references.

  1. Aincrement
  2. Bdecrement
  3. Creassign
  4. DNone of the given

A reference is bound once at initialization and cannot be reseated or moved.

22.
★ Final term 2017 (paper 4)Lecture 34

When we define an array of objects then ______________.

  1. AConstructor will never call
  2. BDepends on the size of array
  3. CConstructor will be called once for whole array
  4. DConstructor will be called for each object of the array

Each element of an array of objects is a separate object, so the constructor runs once per element.

23.
★ Final term solved MCQs (Moaaz & Asad)Lecture 34

When an array of object is created dynamically then there is no way to provide parameterized constructors for array of objects.

  1. ATrue
  2. BFalse

With new Class[n] (classic C++) each element is built with the default constructor.

24.
★ Final term solved MCQs (Moaaz & Asad)Lecture 34

If text is a pointer of class String then what is meant by the following statement? text = new String [5];

  1. ACreates an array of 5 string objects statically
  2. Bcreates an array of 5 string objects dynamically
  3. CCreates an array of pointers to string
  4. DCreates a string Object

new String[5] allocates five String objects on the free store at run time.

25.
★ Final term solved MCQs (Moaaz & Asad)Lecture 34

We can also create an array of user define data type.

  1. ATrue
  2. BFalse

Arrays of structures or class objects are allowed.

26.
★ Final term solved MCQs (Moaaz & Asad)Lecture 34

When we define an array of objects then,

  1. ADestructor will call once for whole array
  2. BDestructor will call for each object of the array
  3. CDestructor will never call
  4. DDepends on the size of array

Every object in the array is destroyed separately, so the destructor runs once per object.

27.
★ Final term 2017 (paper 1)Lecture 35

In C/C++, ________ are the doors through which data can enter and come out of a program.

  1. AStreams
  2. BFields
  3. CVariables
  4. DHeader files

Streams are the channels through which data flows into and out of a program.

28.
★ Final term 2017 (paper 1)Lecture 35

The normal source of cin object is ________.

  1. AFile
  2. BDisk
  3. CKeyboard
  4. DRAM

cin is the standard input stream, normally connected to the keyboard.

29.
★ Final term 2017 (paper 4)Lecture 35

The input/output streams cin and cout are ________ therefore have _______.

  1. AStructures, function
  2. BObjects, member functions
  3. CFunctions, objects
  4. DStructures, non member functions

cin and cout are stream objects, so they have member functions such as get() and put().

30.
★ Final term solved MCQs (Moaaz & Asad)Lecture 35

For cin, the source is normally a ________ and destination can be ______.

  1. AFile, native data type
  2. BDisk, user-define type
  3. CKeyboard, variable
  4. DFile, user-define type

cin reads from the keyboard into an ordinary variable.

31.
★ Final term solved MCQs (Moaaz & Asad)Lecture 35

A stream is an ordered sequence of bytes.

  1. ATrue
  2. BFalse

A stream is a sequence of bytes flowing in order.

32.
★ Final term solved MCQs (Moaaz & Asad)Lecture 35

The input/output streams; cin and cout are ____

  1. AOperators
  2. BFunctions
  3. CObjects
  4. DStructures

cin and cout are stream objects (of istream and ostream).

33.
★ Final term 2017 (paper 1)Lecture 36

Both endl and flush are ________.

  1. AFunctions
  2. BOperators
  3. CManipulators
  4. DObjects

endl and flush are stream manipulators that act on the output stream.

34.
★ Final term 2017 (paper 1)Lecture 36

What will be the output of the following statement? cout << setbase(16) << 52 ;

  1. A52
  2. B34
  3. C64
  4. D32

setbase(16) prints in hexadecimal and 52 decimal is 0x34.

35.
★ Final term 2017 (paper 4)Lecture 36

Which header file should be included in the program to use stream manipulators?

  1. Aiostream.h
  2. Bstdlib.h
  3. Cstdio.h
  4. Diomanip.h

Parameterized manipulators such as setw and setprecision are declared in iomanip.h.

36.
★ Final term solved MCQs (Moaaz & Asad)Lecture 36

width() is member function of _____________

  1. Acin object
  2. Bcout object
  3. CBoth cin and cout object
  4. DNone of the given option

width() is a member of the ios base class, so both input and output streams have it.

37.
★ Final term solved MCQs (Moaaz & Asad)Lecture 36

When we use manipulators in our program then which header file should be included?

  1. Aiostream.h
  2. Bstdlib.h
  3. Cstdio.h
  4. Diomanip.h

Parameterized manipulators are declared in iomanip.h.

38.
★ Final term solved MCQs (Moaaz & Asad)Lecture 36

setprecision is a parameter less manipulator.

  1. ATrue
  2. BFalse

setprecision takes an argument, so it is a parameterized manipulator.

39.
★ Final term solved MCQs (Moaaz & Asad)Lecture 36

setw is a parameterized manipulator.

  1. ATrue
  2. BFalse

setw takes a width argument.

40.
★ Final term solved MCQs (Moaaz & Asad)Lecture 36

dec, hex, oct are all __________

  1. AMember functions
  2. BObjects of input/output streams
  3. CParameterized manipulators
  4. DNon-parameterized manipulators

dec, hex and oct take no arguments.

41.
★ Final term 2017 (paper 1)Lecture 37

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

  1. Aclass for which we overload operator
  2. Breference of ostream class (ostream&)
  3. Creference of istream class (istream&)
  4. Dvoid

operator<< returns ostream& so that insertions can be chained.

42.
★ Final term 2017 (paper 1)Lecture 37

The stream insertion and stream extraction operators are already overloaded for ________.

  1. AUser-defined data types
  2. BBuilt-in data types
  3. CUser-defined and built-in data types
  4. DConstants

The library overloads << and >> for built-in types; user-defined types need their own overloads.

43.
★ Final term 2017 (paper 4)Lecture 37

The stream insertion and extraction operators ____________.

  1. Amust be overloaded as member function
  2. Bmust be overloaded as non-member function
  3. Ccan be overloaded either as member or non-member
  4. Dalways overloaded in class functions

The left operand is a stream object, not the user's class, so << and >> for a user class are overloaded as non-member (usually friend) functions.

44.
★ Final term solved MCQs (Moaaz & Asad)Lecture 37

The first parameter of operator function for << operator,

  1. AMust be passed by value
  2. BMust be passed by reference
  3. CCan be passed by value or reference
  4. DMust be object of class

The ostream argument cannot be copied, so it is taken by reference.

45.
★ Final term solved MCQs (Moaaz & Asad)Lecture 37

The second parameter of operator functions for << and >> are objects of the class for which we are overloading these operators.

  1. ATrue
  2. BFalse

The stream comes first and the class object second, e.g. ostream& operator<<(ostream&, const T&).

46.
★ Final term solved MCQs (Moaaz & Asad)Lecture 37

The first parameter of overloaded stream insertion operator is _________ where second parameter is _______

  1. Ainput stream, object of class
  2. Bobject of class, output stream
  3. Coutput stream, object of class
  4. Dobject of class, input stream

operator<< takes the ostream first and the class object second.

47.
★ Final term solved MCQs (Moaaz & Asad)Lecture 37

The operator function of << and >> operators are always the member function of a class.

  1. ATrue
  2. BFalse

Stream operators are normally non-member (often friend) functions since the stream is the left operand.

48.
★ Final term solved MCQs (Moaaz & Asad)Lecture 38

We can also define a user-defines manipulators.

  1. ATrue
  2. BFalse

C++ lets programmers write their own manipulators.

49.
★ Final term 2017 (paper 1)Lecture 39

A constructor will create a new object with a full copy of the other object, this type of copy is known as ________.

  1. ADeep copy
  2. BShallow copy
  3. CConstructor copy
  4. DObject copy

A deep copy duplicates the pointed-to data too, giving a full independent copy.

50.
★ Final term 2017 (paper 4)Lecture 39

In statement Matrix m2 = m1 ;

  1. AAssignment operator is being used
  2. BCopy constructor is being used
  3. CStatement has syntax error
  4. DStatement has logical error

m2 is being created and initialized from m1 in its declaration, which calls the copy constructor, not operator=.

51.
★ Final term solved MCQs (Moaaz & Asad)Lecture 39

Assignment operator is used to initialize a newly declared object from existing object.

  1. ATrue
  2. BFalse

Initializing a new object from an existing one uses the copy constructor, not the assignment operator.

52.
★ Final term solved MCQs (Moaaz & Asad)Lecture 39

The compiler does not provide a copy constructor if we do not provide it.

  1. ATrue
  2. BFalse

The compiler generates a default member-wise copy constructor when none is written.

53.
★ Solved MCQs collectionLecture 39

The default copy constructor provides member wise assignment.

  1. ATrue
  2. BFalse

The compiler-generated copy constructor copies each member.

54.
★ Final term Spring 2005Lecture 39

A copy constructor

  1. Atakes no arguments
  2. Btakes an arbitrary number of arguments
  3. Ccreates a new object that later may be assigned the data of an existing object
  4. Dcreates an object initialized with the same data as an existing object

A copy constructor builds a new object as a copy of an existing object of the same class.

55.
★ Final term 2017 (paper 1)Lecture 41

A template function must have at least ________ generic data type.

  1. AZero
  2. BOne
  3. CTwo
  4. DThree

A function template needs at least one template type parameter.

56.
★ Final term 2017 (paper 2)Lecture 41

With template function, the compiler automatically detects the ______ and generates ______ using passed data.

  1. Apassed data, a new copy of function
  2. Bparameters, an old copy of function
  3. Cold copy of function, parameters
  4. Dparameters, an new copy of function

The compiler checks the type of the passed data and generates a new instance of the function for it.

57.
★ Final term solved MCQs (Moaaz & Asad)Lecture 41

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

  1. ATrue
  2. BFalse

The compiler deduces the argument types and instantiates a matching function.

58.
★ Final term solved MCQs (Moaaz & Asad)Lecture 41

A template function can have different type of arguments.

  1. ATrue
  2. BFalse

A function template may use several generic types and ordinary types as parameters.

59.
★ Final term solved MCQs (Moaaz & Asad)Lecture 41

A template function must have only generic data types.

  1. ATrue
  2. BFalse

A function template can mix generic and ordinary parameter types.

60.
★ Solved MCQs collectionLecture 41

The template functions do NOT promote the code reuse

  1. ATrue
  2. BFalse

Templates let one definition work for many types, which promotes reuse.

61.
★ Final term solved MCQs (Moaaz & Asad)Lecture 42

Template class cannot have static variables.

  1. ATrue
  2. BFalse

Class templates can have static members; each instantiation gets its own copy.

62.
★ Final term Fall 2005Lecture 42

When we write a class template the first line must be:

  1. Atemplate < class class_type>
  2. Btemplate < class data_type>
  3. Ctemplate < class T >, Here T can be replaced with any name but it is preferable.
  4. Dclass class-name()

A class template begins with template <class T>, where T is a type parameter name.

63.
★ Final term solved paper (vuattach 1)

What will be the output of the following statement? cout << setfill('0') << setw(7) << 128 ;

  1. A0000128
  2. B0128128
  3. C1280000
  4. D0012800

The field is 7 wide and right-justified by default, so 4 fill zeros come before 128.

64.
★ Final term solved paper (vuattach 1)

The stream insertion and extraction operators are not already overloaded for _______

  1. ABuilt-in data types
  2. BUser-defined data types
  3. CBoth built-in and user-defined types
  4. DNone of the given options

<< and >> already work for built-in types; for user-defined types we must overload them.

65.
★ Final term solved paper (vuattach 1)

Template functions can also be overloaded

  1. ATrue
  2. BFalse

Function templates can be overloaded with different numbers or types of parameters.

66.
★ Final term solved paper (vuattach 1)

We can also define a variable of user define data type (object) as static.

  1. ATrue
  2. BFalse

Objects, like built-in variables, can be declared static.

67.
★ Final term solved paper (vuattach 1)

If a class A declares itself a friend of class B and a class B declares itself a friend of class C then

  1. AClass A is also a friend of class C.
  2. BClass B is also a friend of class A.
  3. CClass A is also a friend of class C if A declares C as its friend.
  4. DClass A is also a friend of class C if C declares A as its friend.

Friendship is not transitive; A becomes a friend of C only when C grants it.

68.
★ Final term solved paper (vuattach 1)

When memory for a program is allocated at run time then it is called ________

  1. Astatic memory allocation
  2. Bdynamic memory allocation
  3. Cstack memory allocation
  4. Dvirtual memory allocation

Allocation done while the program runs is dynamic memory allocation.

69.
★ Final term solved paper (vuattach 1)

The following prototype of unary operator function indicates that it is ____________ . Date operator++(int )

  1. AMember functions of post increment operator
  2. BMember functions of pre increment operator
  3. CNon-member functions of post increment operator
  4. DNon-member functions of pre increment operator

The dummy int marks post-increment, and with no object parameter it must be a member function.

70.
★ Final term solved paper (vuattach 1)

If we do not indent the code properly it will __________________

  1. ABe a syntax error
  2. BBe a logical error
  3. CNot be an error at all
  4. DNone of the given options

Indentation only affects readability; the compiler ignores it.

71.
★ Final term solved paper (vuattach 1)

Static memory allocation is also known as ____________

  1. ADynamic allocation
  2. BCompile time allocation
  3. CRun time allocation
  4. DNone of the given options

Static memory is fixed when the program is compiled.

72.
★ Final term solved paper (vuattach 6)

We can use New keyword inside of Class Constructor.

  1. ATrue
  2. BFalse

Constructors often allocate memory with new.

73.
★ Final term solved paper (vuattach 6)

Deleting an array of objects without specifying [] brackets may lead to memory leak

  1. ATrue
  2. BFalse

Without [] only one destructor is called, so memory held by the other objects may leak.

74.
★ Final term solved paper (vuattach 6)

When an operator function is define as member function then operand on the left side of operator must be an object.

  1. ATrue
  2. BFalse

A member operator is called on its left operand, which must be an object of the class.

75.
★ Final term solved paper (vuattach 6)

Every data member or function inside the structure is ___ by default whereas everything declared inside a class is ____ by default.

  1. Aprivate, public
  2. Bpublic, private
  3. Cprivate, protected
  4. Dpublic, protected

Structure members are public by default; class members are private by default.

76.
★ Final term solved paper (vuattach 6)

Which of the following is true for the C++ statement given below? int &ref = val ;

  1. AIt creates a synonym for variable 'val'
  2. BIt creates an alias for variable 'val'
  3. CIt's a new name for variable 'val'
  4. DAll of the given options

A reference is another name (alias, synonym) for an existing variable.

77.
★ Final term solved paper (vuattach 6)

The input/output streams cin and cout are ________ therefore have _______.

  1. AStructures, function
  2. BObjects, member functions
  3. CFunctions, objects
  4. DNone of the given options

cin and cout are stream objects, so they have member functions such as get() and put().

78.
★ Final term solved paper (vuattach 6)

Consider the following code segment. class M { public: M &operator+(const M &); ... }; p + q //code of line implies that p.operator+(q) ... Let assume if p and q are class objects then function is implemented as _______

  1. AMember function
  2. BNon-member function
  3. CFriend function
  4. DNone of the given options

operator+ is declared inside the class with one parameter and called as p.operator+(q).

79.
★ Final term 2017 (paper 1)

The dynamic memory allocation uses memory from the ________.

  1. AStack
  2. BHeap
  3. CSystem Cache
  4. DSecondary Storage

Dynamically allocated memory comes from the heap (free store).

80.
★ Final term 2017 (paper 1)

When a value is referred by a normal variable then it is known as ________.

  1. ADirect Reference
  2. BIndirect Reference
  3. CProper Reference
  4. DPartial Reference

Using the variable name directly is direct reference; access through a pointer is indirect reference.

81.
★ Final term 2017 (paper 1)

The operator used for casting in C is standard ________ operator.

  1. Abinary
  2. Bcast
  3. Ccost
  4. Dconst

C uses the cast operator (type) to convert a value to another type.

82.
★ Final term 2017 (paper 1)

new operator allocates memory from free store and returns ________.

  1. AA pointer
  2. BA reference
  3. CAn integer
  4. DA float

new returns a pointer to the allocated memory.

83.
★ Final term 2017 (paper 1)

The pointer returned by the new operator points to ________ of memory chunks allocated by the new operator.

  1. ASecond memory address
  2. BFirst memory address
  3. CLast memory address
  4. DLast memory address of the previous chunk

new returns the starting (first) address of the allocated block.

84.
★ Final term 2017 (paper 1)

What does STL stand for?

  1. ASource template library
  2. BStandard template library
  3. CStream template library
  4. DStandard temporary library

STL is the C++ Standard Template Library.

85.
★ Final term 2017 (paper 1)

The appropriate data type to store the number of rows and colums of the matrix is ________.

  1. Afloat
  2. Bstrings
  3. Cint
  4. Dchar

Row and column counts are whole numbers, so int is appropriate.

86.
★ Final term 2017 (paper 1)

By using objects as class members, ________ is achieved.

  1. AAccessibility
  2. BReliability
  3. CReusability
  4. DUsability

Using existing class objects as members (composition) reuses existing code.

87.
★ Final term 2017 (paper 1)

________ data members of a contained object can be accessed from inside of the containing class.

  1. APrivate
  2. BPublic
  3. CProtected
  4. DAll

The containing class is not a friend or derived class, so it can access only the public members of the contained object.

88.
★ Final term 2017 (paper 1)

When an object of a class is defined inside an other class then ________.

  1. AConstructor of enclosing class will be called first
  2. BConstructor of inner object will be called first
  3. CConstructor and Destructor will be called simultaneously
  4. DOnly destructor will be called

Member objects are constructed before the body of the enclosing class constructor runs.

89.
★ Final term 2017 (paper 1)

The order of destruction of an object is ________.

  1. Asame as the construction order.
  2. Breverse as the construction order.
  3. Cindependent of the construction order.
  4. Dsame as the order of objects declared.

Objects are destroyed in the reverse order of their construction.

90.
★ Final term 2017 (paper 1)

________ is the only operator that the compiler overloads for user defined data type.

  1. APlus (+)
  2. BMinus (-)
  3. CEqual (= =)
  4. DAssignment (=)

The compiler supplies a default member-wise assignment operator for classes.

91.
★ Final term 2017 (paper 1)

A class member function defined for overloading a unary operator takes how many arguments ?

  1. AZero
  2. BOne
  3. CTwo
  4. DN arguments

For a member unary operator the single operand is the calling object, so no argument is passed.

92.
★ Final term 2017 (paper 1)

The region of memory, available for allocation at run time in C language is called ________ memory whereas in C++, is called ________.

  1. AHeap, Stack
  2. BStack, Free Store
  3. CHeap, Free Store
  4. DFree store, Heap

C calls run-time allocatable memory the heap; C++ calls it the free store.

93.
★ Final term 2017 (paper 1)

Which one of the given options is correct prototype syntax for overloaded operator?

  1. Areturn-type operator-symbol (parameter-list) operator;
  2. Boperator return-type operator-symbol (parameter-list);
  3. Creturn-type operator operator-symbol (parameter-list);
  4. Dreturn-type operator-symbol operator (parameter-list);

The form is return-type operator symbol(parameters), e.g. int operator+(int).

94.
★ Final term 2017 (paper 1)

The declarator of Plus (+) member operator function is ________.

  1. AClass-Name operator + (Class-Name rhs)
  2. Boperator Class-Name + ( )
  3. Coperator Class-Name + ( rhs)
  4. DClass-Name operator + ( )

A binary member operator+ returns the class type and takes the right-hand operand as its one parameter.

95.
★ Final term 2017 (paper 1)

Sequence of event(s) when allocating memory using new operator is ________.

  1. AOnly block of memory is allocated for objects
  2. BOnly constructor is called for objects
  3. CMemory is allocated first before calling constructor
  4. DConstructor is called first before allocating memory

new first obtains memory and then runs the constructor on that memory.

96.
★ Final term 2017 (paper 1)

Whenever we allocate any memory from the ________ then starting position of the block of the memory allocated is returned as an address that is kept in a pointer.

  1. AFlush
  2. BBuffer
  3. CHeap
  4. DStack

Dynamic allocation takes memory from the heap and returns its starting address.

97.
★ Final term 2017 (paper 1)

Whenever we allocate any memory from the heap then starting position of the block of the memory allocated is returned as a ________ that is kept in a pointer.

  1. AVariable
  2. BAddress
  3. CPointer
  4. DArray

The start of the allocated block is returned as an address, which is stored in a pointer.

98.
★ Final term 2017 (paper 1)

Constructor is a special function, called whenever we instantiate a ________ of a class.

  1. AFunction
  2. BData member
  3. CObject
  4. DPointer

Instantiating an object of a class automatically calls its constructor.

99.
★ Final term 2017 (paper 2)

Using a segment of source code again by adding new functionalities with slight or no modification is termed as ______.

  1. Acode efficiency
  2. Bcode reusability
  3. Ccode modification
  4. Dcode compatibility

Reusing existing code with little or no change is code reusability.

100.
★ Final term 2017 (paper 2)

In windows operating system, function calling is like sending a/an ______ to the object.

  1. AError
  2. BMessage
  3. CRequest
  4. DObject

In Windows (and OOP terms) calling a function on an object is described as sending it a message.

101.
★ Final term 2017 (paper 2)

The static data members of a class will be ______.

  1. Ashared by objects
  2. Bcreated for each object
  3. Cinitialized within class
  4. Dinitialized within main function

A static data member has one copy that all objects of the class share; it is defined/initialized outside the class.

102.
★ Final term 2017 (paper 2)

Which of the following option is true about static data members of a class?

  1. AThe static data members cannot be private or public
  2. BThe static data members must be private
  3. CThe static variables must be public
  4. DThe static data members can be private or public

Static data members follow normal access rules and can be declared private or public.

103.
★ Final term 2017 (paper 2)

When a variable is defined as static in a class then ______.

  1. ASeparate copy of this variable is created for each object
  2. BOnly one copy is created for all objects of this class
  3. CA copy of this variable is created for only static objects
  4. DNo copy is created for the objects of that class

A static class member exists once per class, shared by all objects.

104.
★ Final term 2017 (paper 2)

Which of the following operator the compiler overloads for objects by default?

  1. A+ operator
  2. B- operator
  3. C= operator
  4. D== operator

The compiler supplies a default assignment operator that copies members.

105.
★ Final term 2017 (paper 2)

Templates provide way of abstracting ______ information.

  1. Atype
  2. Bdata
  3. Cmethod
  4. Daccess

Templates let code be written independent of the data type.

106.
★ Final term 2017 (paper 2)

Classes defined inside other classes are called ______ classes

  1. Alooped
  2. Bnested
  3. Coverloaded
  4. Dchildren classes

A class declared inside another class is a nested class.

107.
★ Final term 2017 (paper 2)

If we write a statement like s2 = s1; ______ will be the calling object and ______ will be passed to the = operator as an argument.

  1. As1, s1
  2. Bs1, s2
  3. Cs2, s1
  4. Ds2, s2

The left operand s2 calls operator= and the right operand s1 is the argument.

108.
★ Final term 2017 (paper 2)

We can use cin.peek() function to ______.

  1. ASee the next character that we are going to get.
  2. BGet to the end of the input buffer.
  3. CSee the first character of input buffer.
  4. DSee the last character of the current input word.

peek() returns the next character in the input stream without extracting it.

109.
★ Final term 2017 (paper 2)

new and delete are also used with ______ and primitive data types as well.

  1. Aloops
  2. Bstructures, pointers
  3. Cclasses, structures
  4. Dconstant

new and delete work with class and structure objects as well as built-in types.

110.
★ Final term 2017 (paper 2)

Memory allocated at run time is a system resource and it is the responsibility of ______ to de-allocate the memory.

  1. ASystem
  2. BProgrammer
  3. CUser of program
  4. DOperating System

Dynamically allocated memory must be freed by the programmer with delete/free.

111.
★ Final term 2017 (paper 2)

While overloading new and delete operators, we should take care that ______.

  1. AThey should be overloaded for specific types instead of overloading globally.
  2. BBoth of these operators should not be overloaded in the same program.
  3. CWe should never overload either of these operators.
  4. DThey should be not overloaded for specific types instead of overloading globally.

Overloading new/delete for a specific class avoids affecting every allocation in the program.

112.
★ Final term 2017 (paper 2)

A constructor has the same name as that of ______.

  1. AVariable
  2. BClass
  3. CStructure
  4. DFunction

A constructor is named exactly like its class.

113.
★ Final term 2017 (paper 2)

The destructor for all the objects in the program is automatically called when ______.

  1. AMemory is dynamically allocated to objects
  2. BObjects are used inside functions
  3. CArray of objects is declared
  4. DProgram is terminated

At program termination, destructors of remaining (static/global) objects run automatically.

114.
★ Final term 2017 (paper 3)

When an argument is passed by reference, ____.

  1. Athe function cannot access the argument's value
  2. Ba variable is created in the function to hold the argument's value
  3. Ca temporary variable is created in the calling program to hold the argument's value
  4. Dthe function accesses the argument's original value in the calling program

With pass by reference the function works directly on the caller's original variable, not a copy.

115.
★ Final term 2017 (paper 3)

The member functions of a class occupy ____ region in memory for ____ object(s) of class.

  1. Aseparate, each
  2. Bcommon, all
  3. Cdifferent, each
  4. Ddifferent, all

Only one copy of member function code exists and is shared by all objects; only data members are per object.

116.
★ Final term 2017 (paper 3)

The static data members of a class are initialized ____.

  1. Aat file scope
  2. Bwithin class definition
  3. Cwithin member function
  4. Dwithin main function

A non-const static data member is declared in the class but defined and initialized outside it at file scope.

117.
★ Final term 2017 (paper 3)

The static data members of a class can be accessed by ____.

  1. Aonly class
  2. Bonly objects
  3. Cboth class and objects
  4. Dfunction out side the class

A public static member can be reached with the class name (ClassName::member) or through any object.

118.
★ Final term 2017 (paper 3)

Static variable which is defined in a function is initialized ____.

  1. AEvery time the function call
  2. BOnly once during its life time
  3. CFor many times in the program
  4. DCompile time of the program

A static local variable is initialized only once and keeps its value between calls.

119.
★ Final term 2017 (paper 3)

The code is written to ____ the program.

  1. Aimplement
  2. Bdesign
  3. Canalysis
  4. Dtest

Writing code is the implementation step of developing a program.

120.
★ Final term 2017 (paper 3)

The initializer list is used to initialize the contained objects of a class at ____.

  1. ARun time
  2. BDebugging time
  3. CConstruction time
  4. DCompile time

The member initializer list runs when the containing object is constructed, before the constructor body.

121.
★ Final term 2017 (paper 3)

Which is NOT a protection level provided by classes in C++?

  1. Aprotected
  2. Bhidden
  3. Cprivate
  4. Dpublic

C++ access specifiers are only public, private and protected; there is no 'hidden'.

122.
★ Final term 2017 (paper 3)

What should be the return type of the constructor?

  1. Avoid pointer
  2. Bint
  3. Csame as object type
  4. Dconstructors do not return any thing

A constructor has no return type, not even void.

123.
★ Final term 2017 (paper 3)

Which of the following function cannot be overloaded?

  1. AMember functions
  2. BUtility functions
  3. CConstructor
  4. DDestructor

A destructor takes no arguments, so a class can have only one and it cannot be overloaded.

124.
★ Final term 2017 (paper 3)

Users must not know about ____.

  1. AMethods functionality with in class
  2. BObjects of class
  3. CFunctions name within class
  4. DClass implementation of functionality and interfaces

Data hiding keeps how the methods work inside the class away from the users; they only use the public interface.

125.
★ Final term 2017 (paper 3)

Consider the following code segment. class M { public: M &operator+(const M &); ... }; p + q //code of line implies that p.operator+(q) ... Let assume if p and q are class objects then function is implemented as ____.

  1. AMember function
  2. BNon-member function
  3. CFriend function
  4. DVirtual function

p + q becoming p.operator+(q) means the operator is a member function called on the left operand.

126.
★ Final term 2017 (paper 3)

Sequence of event(s) when deallocating memory using delete operator is ____.

  1. AOnly block of memory is deallocated for objects
  2. BOnly destructor is called for objects
  3. CMemory is deallocated first before calling destructor
  4. DDestructor is called first before deallocating memory

delete first calls the object's destructor and then frees its memory.

127.
★ Final term 2017 (paper 3)

Whenever new operator is called to create an object, the ____ is also called for that object.

  1. AConstructor
  2. BDestructor
  3. CPointer
  4. DArray

new allocates memory and then calls the constructor to initialize the object.

128.
★ Final term 2017 (paper 4)

The purpose of using cout<< is to __________.

  1. ADisplay information on the screen
  2. BRead the data from keyboard
  3. CRead the data from a file
  4. DWrite into a file

cout is the standard output stream, normally the screen.

129.
★ Final term 2017 (paper 4)

Which header file should be included to use functions like malloc() and calloc()?

  1. Amemory.h
  2. Biostream.h
  3. Cstdlib.h
  4. Dconio.h

malloc, calloc, realloc and free are declared in stdlib.h (cstdlib).

130.
★ Final term 2017 (paper 4)

The programs in which we allocate static memory run essentially on ________.

  1. AHeap
  2. BSystem Cache
  3. CFree Store
  4. DStack

Statically declared (automatic) variables are allocated on the stack; dynamic memory comes from the heap/free store.

131.
★ Final term 2017 (paper 4)

TWAIN stands for _________.

  1. ATechnology With An Interesting Name
  2. BTechnology Without An Informative Name
  3. CTechnology Without An Interesting Name
  4. DTechnology With An Informative Name

TWAIN is commonly expanded as Technology Without An Interesting Name.

132.
★ Final term 2017 (paper 4)

Which of the following is true while overloading operators?

  1. APrecedence of an operator can be changed
  2. BThe arity (number of operands) can be changed
  3. CNo new operators can be created
  4. DAssociativity of an operator can be changed

Operator overloading cannot invent new operators, nor change precedence, associativity or arity.

133.
★ Final term 2017 (paper 4)

Which of the following is true about operator overloading?

  1. AThe operator works with only objects of the class in which it is overloaded.
  2. BThe operator works with objects and primitive data types regardless of parameters.
  3. CThe operator works with both objects and primitive data types depending on parameters.
  4. DThe operator must have a constant and an object as parameters.

An overloaded operator accepts whatever operand types its parameter list declares, so it can mix objects and built-in types.

134.
★ Final term 2017 (paper 4)

ANSI stands for _________.

  1. AAsian National Standards Institute
  2. BAmerican National Standards Institute
  3. CAmerican Neutral Standards Institute
  4. DAustralian National Standards Institute

ANSI is the American National Standards Institute.

135.
★ Final term 2017 (paper 4)

Which of the following option will be true, if we overload "-=" operator?

  1. Aonly - operator needs to be overloaded
  2. BMinus (-) and = operators need to be overloaded
  3. Cthe -= operator need to be overloaded explicitly
  4. Dthe - and = operators need to be overloaded implicitly

Overloading - and = does not give you -=; the compound operator must be overloaded separately.

136.
★ Final term 2017 (paper 4)

In operator overloading, a non-member unary operator function takes _______ arguments.

  1. A0
  2. B2
  3. C1
  4. D3

A non-member function has no implicit this, so its single operand is passed as one argument.

137.
★ Final term 2017 (paper 4)

Which of the following statement is true about Assignment operator (=) and output stream 'cout'?

  1. AAssignment operator is left associative whereas cout is right associative.
  2. BAssignment operator is right associative whereas cout is left associative.
  3. CBoth (Assignment operator, output stream 'cout') are right associative.
  4. DBoth (Assignment operator, output stream 'cout') are left associative.

a = b = c groups right to left, while cout << x << y groups left to right.

138.
★ Final term 2017 (paper 4)

If text is a pointer of class String then purpose of statement below is to __________. text = new String [5];

  1. ACreate an array of 5 string objects statically
  2. BCreate an array of 5 string objects dynamically
  3. CCreate an array of pointers to String
  4. DCreate an object of String

new String[5] allocates an array of five String objects on the heap at run time.

139.
★ Final term 2017 (paper 4)

Which value is returned by the destructor of a class?

  1. AA pointer to the class.
  2. BAn object of the class.
  3. CA status code determining whether the class was destructed correctly
  4. DDestructors do not return a value.

Destructors have no return type and return nothing.

140.
★ Final term 2017 (paper 4)

(*this) represents ________.

  1. AThe current function of the class
  2. BThe current pointer of the class
  3. CThe current object of the class
  4. DA value of the data member

this points to the object the member function was called on, so *this is that current object.

141.
★ Final term solved MCQs (Moaaz & Asad)

Which one of the following is the declaration of overloaded pre-increment operator implemented as member function?

  1. AClass-name operator +() ;
  2. BClass-name operator +(int) ;
  3. CClass-name operator ++() ;
  4. DClass-name operator ++(int) ;

Prefix ++ as a member takes no parameters; the dummy int parameter marks postfix.

142.
★ Final term solved MCQs (Moaaz & Asad)

Class is a user defined___________.

  1. Adata type
  2. Bmemory referee
  3. Cvalue
  4. Dnone of the given options.

A class defines a new user-defined data type.

143.
★ Final term solved MCQs (Moaaz & Asad)

Which of the following is the correct C++ syntax to allocate space dynamically for an array of 10 int?

  1. Anew int(10) ;
  2. Bnew int[10] ;
  3. Cint new(10) ;
  4. Dint new[10];

new int[10] allocates an array of 10 ints; new int(10) allocates one int initialized to 10.

144.
★ Final term solved MCQs (Moaaz & Asad)

Operator overloading can be performed through__________________.

  1. AClasses
  2. BFunction
  3. COperators
  4. DReference

An operator is overloaded by writing an operator function.

145.
★ Final term solved MCQs (Moaaz & Asad)

Which of the following function is used to increase the size of already allocated memory chunk?

  1. Amalloc
  2. Bcalloc
  3. Crealloc
  4. Dfree

realloc resizes a previously allocated memory block.

146.
★ Final term solved MCQs (Moaaz & Asad)

Overloaded delete operator function takes the same parameter as an argument returned by new operator function.

  1. ATrue
  2. BFalse

operator delete receives the pointer that operator new returned.

147.
★ Final term solved MCQs (Moaaz & Asad)

We can not define a function as a friend of a Template class.

  1. ATrue
  2. BFalse

Class templates can have friend functions and friend function templates.

148.
★ Final term solved MCQs (Moaaz & Asad)

new and delete are _____ whereas malloc and free are _____.

  1. AFunctions, operators
  2. BClasses, operators
  3. COperators, functions
  4. DOperators, classes

new/delete are C++ operators; malloc/free are C library functions.

149.
★ Final term solved MCQs (Moaaz & Asad)

Which situation would require the use of a non-member overloaded operator?

  1. AThe overloaded operator is an Assignment operator.
  2. BThe left most operand is an object of a class.
  3. CThe left operand is built-in data type.
  4. DThe operator returns a reference.

A member operator needs a class object on the left, so a built-in left operand requires a non-member.

150.
★ Final term solved MCQs (Moaaz & Asad)

When ever dynamic memory allocation is made in C/C++, it is freed_____________.

  1. AExplicitly
  2. BImplicitly
  3. CBoth explicitly and implicitly
  4. DNone of the given options

Dynamically allocated memory must be released explicitly with free or delete.

151.
★ Final term solved MCQs (Moaaz & Asad)

Which of the following function do NOT initialize the chunk of memory to all zero?

  1. Acalloc() function
  2. BBoth malloc() and calloc()
  3. CNone of the above
  4. Dmalloc() function

malloc leaves memory uninitialized while calloc zero-fills it.

152.
★ Final term solved MCQs (Moaaz & Asad)

The function free() returns back the allocated memory got thorough calloc and malloc to _____ .

  1. Astack
  2. Bheap
  3. Cstack and heap
  4. DNone of the given options

calloc and malloc allocate from the heap, and free returns memory there.

153.
★ Final term solved MCQs (Moaaz & Asad)

Templates are not type safe.

  1. ATrue
  2. BFalse

Template types are known at compile time, so the compiler type-checks them.

154.
★ Final term solved MCQs (Moaaz & Asad)

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

  1. AWrite a separate class to handle each
  2. BUse templates
  3. CUse strings to store all types
  4. DNone of the given options

A class template handles all element types with one definition.

155.
★ Final term solved MCQs (Moaaz & Asad)

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

  1. ATrue
  2. BFalse

These are stream-state member functions, not manipulators like endl or setw.

156.
★ Final term solved MCQs (Moaaz & Asad)

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

  1. AFriend functions of the class
  2. BPrivate member functions of the class
  3. CPublic member functions of the class
  4. DFriend, private and public functions

All member functions (private or public) and friends can access private members.

157.
★ Final term solved MCQs (Moaaz & Asad)

The return type of operator function must always be void.

  1. ATrue
  2. BFalse

Operator functions may return any type, such as a reference or an object.

158.
★ Final term solved MCQs (Moaaz & Asad)

Heap is constantly changing in size.

  1. ATrue
  2. BFalse

The heap grows and shrinks as memory is allocated and freed at run time.

159.
★ Final term solved MCQs (Moaaz & Asad)

While calling function, the arguments are assigned to the parameters from _____________.

  1. Aleft to right.
  2. Bright to left
  3. Cno specific order is followed
  4. Dnone of the given options.

Arguments are matched to parameters by position starting from the left.

160.
★ Final term solved MCQs (Moaaz & Asad)

Classes defined inside other classes are called ________ classes

  1. Alooped
  2. Bnested
  3. Coverloaded
  4. Dnone of the given options.

A class declared inside another class is a nested class.

161.
★ Final term solved MCQs (Moaaz & Asad)

Every class contains _______________.

  1. AConstructor
  2. BDestructor
  3. CBoth a constructor and a destructor
  4. DNone of the given options

If not written, the compiler supplies a default constructor and destructor.

162.
★ Final term solved MCQs (Moaaz & Asad)

Structured Query Language is used for ______________

  1. ADatabases Management
  2. BNetworks
  3. CWriting Operating System
  4. Dnone of the given options

SQL is the language for querying and managing relational databases.

163.
★ Final term solved MCQs (Moaaz & Asad)

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

  1. ATrue
  2. BFalse

Local (automatic) variables are destroyed when the function returns.

164.
★ Final term solved MCQs (Moaaz & Asad)

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

  1. ATrue
  2. BFalse

Overloading cannot change an operator's precedence, associativity or arity.

165.
★ Final term solved MCQs (Moaaz & Asad)

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

  1. ATrue
  2. BFalse

delete releases memory obtained with new back to the free store.

166.
★ Final term solved MCQs (Moaaz & Asad)

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

  1. ATrue
  2. BFalse

obj1 = obj2 becomes obj1.operator=(obj2).

167.
★ Final term solved MCQs (Moaaz & Asad)

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

  1. AOne, zero
  2. BZero, one
  3. COne, two
  4. DTwo, one

A member gets its operand via this, so it takes none; a non-member takes the operand as one argument.

168.
★ Final term solved MCQs (Moaaz & Asad)

The statement cin.get (); is used to,

  1. ARead a string from keyboard
  2. BRead a character from keyboard
  3. CRead a string from file
  4. DRead a character from file

cin.get() with no arguments extracts a single character from standard input.

169.
★ Final term solved MCQs (Moaaz & Asad)

When we do dynamic memory allocation in the constructor of a class, then it is necessary to provide a destructor.

  1. ATrue
  2. BFalse

A destructor is needed to delete memory the constructor allocated, or it leaks.

170.
★ Final term solved MCQs (Moaaz & Asad)

Overloaded new operator function takes parameter of type size_t and returns

  1. Avoid (nothing)
  2. Bvoid pointer
  3. Cobject pointer
  4. Dint pointer

operator new has the signature void* operator new(size_t).

171.
★ Final term solved MCQs (Moaaz & Asad)

The default value of a parameter can be provided inside the ________________

  1. Afunction prototype
  2. Bfunction definition
  3. Cboth function prototype or function definition
  4. Dnone of the given options.

A default argument can be given in either the prototype or the definition, but not repeated in both.

172.
★ Final term solved MCQs (Moaaz & Asad)

What purpose do classes serve?

  1. AData encapsulation
  2. BProviding a convenient way of modeling real-world objects
  3. CSimplifying code reuse
  4. DAll of the given options

Classes give encapsulation, real-world modeling and reuse together.

173.
★ Final term solved MCQs (Moaaz & Asad)

new operator is used to allocate memory from the free store during

  1. ACompile Time
  2. BRun Time
  3. CLink Time
  4. DNone of the given options

new allocates memory dynamically while the program runs.

174.
★ Final term solved MCQs (Moaaz & Asad)

When an object of a class is defined inside another class then,

  1. ADestructor of enclosing class will be called first
  2. BDestructor of inner object will be called first
  3. CConstructor and Destructor will be called simultaneously
  4. DNone of the given options

Destruction reverses construction: the enclosing destructor runs first, then the member objects' destructors.

175.
★ Final term solved MCQs (Moaaz & Asad)

It is possible to define a class within another class.

  1. ATrue
  2. BFalse

C++ supports nested classes.

176.
★ Final term solved MCQs (Moaaz & Asad)

New and Delete are also used with ___________ and data types as well.

  1. AClass, Objects
  2. BStructures, Pointers
  3. CBoth Class and structures
  4. DNone of above

new and delete create and destroy class objects as well as built-in types.

177.
★ Final term solved MCQs (Moaaz & Asad)

When new operator is overloaded at global level then corresponding built-in new operator will not be visible to whole of the program.

  1. ATrue
  2. BFalse

A global operator new replaces the built-in one for the whole program.

178.
★ Final term solved MCQs (Moaaz & Asad)

The operator function overloaded for an Assignment operator (=) must be

  1. ANon-member function of class
  2. BMember function of class
  3. CFriend function of class
  4. DNone of the given options

C++ requires operator= to be a non-static member function.

179.
★ Final term solved MCQs (Moaaz & Asad)

Constructors can not be overloaded like ordinary functions.

  1. ATrue
  2. BFalse

Constructors can be overloaded with different parameter lists, just like ordinary functions.

180.
★ Final term solved MCQs (Moaaz & Asad)

When an operator function is defined as member function for a binary Plus (+) operator then the number of argument it take is/are.

  1. AZero
  2. BOne
  3. CTwo
  4. DN arguments

A member binary operator receives the left operand through this, so it takes only one explicit argument.

181.
★ Final term solved MCQs (Moaaz & Asad)

We can not define a variable of user-defined data type in the class.

  1. ATrue
  2. BFalse

A class can contain data members whose type is another user-defined type (composition).

182.
★ Final term solved MCQs (Moaaz & Asad)

What is the sequence of event(s) when allocating memory using new operator?

  1. AOnly block of memory is allocated for objects
  2. BOnly constructor is called for objects
  3. CMemory is allocated first before calling constructor
  4. DConstructor is called first before allocating memory

new first obtains memory, then runs the constructor on that memory.

183.
★ Final term solved MCQs (Moaaz & Asad)

If overloaded plus operator is implemented as non-member function then which of the following statement will be true for the statement given below? obj3 = obj1 + obj2 ;

  1. Aobj2 will be passed as an argument to + operator whereas obj2 will drive the + operator
  2. Bobj1 will drive the + operator whereas obj2 will be passed as an argument to + operator
  3. CBoth objects (obj1, obj2) will be passed as arguments to the + operator
  4. DAny of the objects (obj1, obj2) can drive the + operator

A non-member binary operator receives both operands as parameters.

184.
★ Final term solved MCQs (Moaaz & Asad)

With user-defined data type variables (Objects), self assignment can produce __________.

  1. ASyntax error
  2. BLogical error
  3. CLink error
  4. DNon of the given options

Self assignment compiles fine but can corrupt data (e.g. freeing memory before copying), a logical error.

185.
★ Final term solved MCQs (Moaaz & Asad)

In the member initializer list, the data members are initialized,

  1. AFrom left to right
  2. BFrom right to left
  3. CIn the order in which they are defined within class
  4. DNone of the given options

Members are always initialized in declaration order, regardless of the list order.

186.
★ Final term solved MCQs (Moaaz & Asad)

"new" and "delete" keywords are _____________ in C++ language.

  1. ABuilt-in- Function
  2. BOperators
  3. CMemory Allocation Function
  4. DNone of the given options

new and delete are C++ operators (they can even be overloaded).

187.
★ Final term solved MCQs (Moaaz & Asad)

Disks are _______________ devices having access time of _________ milliseconds.

  1. AElectro-physical, 6
  2. BElectro-Mechanical, 4
  3. CElectro-physical, 5
  4. DElectro-Mechanical, 7

The course handout describes disks as electro-mechanical with about 7 ms access time.

188.
★ Final term solved MCQs (Moaaz & Asad)

We can not make a member function of a class as template function.

  1. ATrue
  2. BFalse

Member functions can themselves be templates.

189.
★ Final term solved MCQs (Moaaz & Asad)

Overloaded delete operator function takes parameter of void pointer and returns ________.

  1. Avoid
  2. Bvoid pointer
  3. Cpointer to an object
  4. Dpointer of type int

operator delete is declared as void operator delete(void*).

190.
★ Final term solved MCQs (Moaaz & Asad)

It is a way of reusing the code when we contain objects of our already written classes into a new class,

  1. ATrue
  2. BFalse

Composition reuses existing classes by containing their objects.

191.
★ Final term solved MCQs (Moaaz & Asad)

new and delete operators cannot be overloaded as member functions.

  1. ATrue
  2. BFalse

new and delete can be overloaded as class member functions.

192.
★ Final term solved MCQs (Moaaz & Asad)

Reusing the variables in program helps to save the memory

  1. ATrue
  2. BFalse

Reusing a variable instead of declaring new ones avoids extra memory allocation.

193.
★ Final term solved MCQs (Moaaz & Asad)

Which of the following option is true about new operator to dynamically allocate memory to an object?

  1. AThe new operator determines the size of an object
  2. BAllocates memory to object and returns pointer of valid type
  3. CCreates an object and calls the constructor to initialize the object
  4. DAll of the given options

new computes the size, allocates, constructs the object and returns a typed pointer.

194.
★ Final term solved MCQs (Moaaz & Asad)

For non-member operator function, object on left side of the operator may be

  1. AObject of operator class
  2. BObject of different class
  3. CBuilt-in data type
  4. DAll of the given options

A non-member operator does not require its left operand to be an object of the class.

195.
★ Final term solved MCQs (Moaaz & Asad)

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;

  1. AMember function
  2. BNon-member function
  3. CFriend function
  4. DNone of the given options

When the left operand drives the call, the operator is a member function of its class.

196.
★ Final term solved MCQs (Moaaz & Asad)

Automatic variable are created on ________.

  1. AHeap
  2. BFree store
  3. Cstatic storage
  4. Dstack

Automatic (local) variables live on the stack.

197.
★ Final term solved MCQs (Moaaz & Asad)

Which of the following is a valid class declaration?

  1. Aclass A { int x; };
  2. Bclass B { }
  3. Cpublic class A { }
  4. Dobject A { int x; };

A C++ class declaration uses the class keyword and ends with a semicolon.

198.
★ Solved MCQs collection

Which of the following object(s) will call the member operator function within the statement given below? obj1=obj2+obj3;

  1. AObject obj1
  2. BObject obj2
  3. CObject obj3
  4. DAny of the object

The left operand of + (obj2) invokes the member operator function.

199.
★ Solved MCQs collection

We can delete an array of objects without specifying [] brackets if a class is not doing dynamic memory allocation internally.

  1. ATrue
  2. BFalse

Arrays allocated with new[] must always be released with delete[].

200.
★ Past paper collection

For binary member operators, operands on the ___________ drives (calls) the operation.

  1. ALeft
  2. BRight
  3. CBoth left and right
  4. DNone of the given

For a member operator function the left operand is the object whose member function is called.

201.
★ Past paper collection

The ________ is called automatically when an object destroys

  1. Adestructor
  2. Bconstructor
  3. Cmain program
  4. Ddefault constructor

The destructor runs automatically when an object goes out of scope or is deleted.

202.
★ Past paper collection

The destructor is used to ____________.

  1. Aallocate memory
  2. Bdeallocate memory
  3. Ccreate objects
  4. Dallocate static memory

A destructor does clean-up such as releasing memory the object allocated.

203.
★ Past paper collection

___________data isn't accessible by non-member functions or outside classes.

  1. APublic
  2. Bprivate
  3. CStatic
  4. DGlobally declared

Private members can be used only by the class's own member (and friend) functions.

204.
★ Past paper collection

Member functions of the class ________ main program.

  1. Aare not accessible
  2. Bare accessible from
  3. Care defined within the
  4. Dare private to

Public member functions can be called from main through an object.

205.
★ Past paper collection

You cannot overload the _____________ operator

  1. A? :
  2. B*
  3. C/
  4. D++

The conditional operator ?: is one of the operators C++ does not allow to be overloaded.

206.
★ Final term Fall 2005

A function declaration has the same relationship to a function definition that

  1. Aa class definition has to an object definition
  2. Ban object declaration has to an object
  3. Ca variable has to a variable declaration
  4. Da variable declaration has to the variable itself

A declaration only announces the name and type; the definition is the thing itself, as with a variable declaration and the variable.

207.
★ Final term Fall 2005

There is a class Student, Which one of the following is a valid destructor for this class.

  1. AStudent();
  2. BStudent(int);
  3. C~ Student();
  4. Dint~ Student();

A destructor is ~ClassName() with no return type and no parameters.