Paper Tayyari

Lecture 34: Arrays of Objects

MCQs, short and long questions from lecture 34.Lecture 34 ki MCQs, short aur long sawal.

5 MCQs · 5 MCQs from past papers5 MCQs · 5 MCQs past papers se

Start mock testMock test shuru karein
DoneHal kiye 0/5
– correctsahi
1.
★ Final term 2017 (paper 4)

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.

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

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.

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

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.

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

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

  1. ATrue
  2. BFalse

Arrays of structures or class objects are allowed.

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

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.