Memory Allocation and Variable Scope Mcqs

Our collections of Multiple choice questions and answers focuses on study of Memory Allocation and Variable Scope in OOP. These questions are chosen from a collection of most authoritative and best reference books on OOP. Our aim is to prepare an individual for competitive exams like NTS, Web Developer | IOS Developer | Game Developer | Software House interviews and jobs, University and College entrance exams and various tests and job interviews. One should practice our Mcqs to assimilate IMemory Allocation and Variable Scope in OOP comprehensively.

What is new operator?

Allocates memory for an object or array

Allocates memory for an object or array and returns a particular pointer

Used as return type when an object is created

Used to declare any new thing in a program

Microsoft C++ Components extensions support new keyword to _____________

Modify a vtable

Replace a vtable slot entry

Add new vtable slot entries

Rearrange vtable slot entries

What happens when new fails?

Returns zero always

Throws an exception always

Either throws an exception or returns zero

Terminates the program

In C++, if new operator is used, when is the constructor called?

Before the allocation of memory

After the allocation of memory

Constructor is called to allocate memory

Depends on code

Which among the following is correct syntax to declare a 2D array using new operator?

Char (*pchar)[10] = new char[][10],

Char (pchar) = new char[][10],

Char (*char) = new char[10][],

Char (*char)[][10]= new char,

For declaring data by using new operator ____________________

Type name can’t contain const

Type name can’t contain volatile

Type name can’t contain class declarations

Type name can’t contain const, volatile, class declaration or enumerations

The new operator _____________

Can allocate reference types too

Doesn’t allocate reference types

Can allocate reference to objects

Doesn’t allocate any data

Which among the following is correct?

New operator can’t allocate functions but pointer to functions can be allocated

New operator can allocate functions as well as pointer to functions

New operator can allocate any type of functions

New operator is not applicable with functions allocation

Initializers __________________

Are used for specifying arrays

Are used to defined multidimensional arrays

Can’t be specified for arrays

Can’t be specified for any data

The objects allocated using new operator ________________

Are destroyed when they go out of scope

Are not destroyed even if they go out of scope

Are destroyed anytime

Are not destroyed throughout the program execution

The new operator _________________

Invokes function operator new

Doesn’t invoke function operator new

Invokes function operator only if required

Can’t invoke function operator new implicitly

If new operator is defined for a class and still global new operator have to be used, which operator should be used with the keyword new?




Scope resolution

How does compiler convert “::operator new” implicitly?

::operator new( sizeof( type ) )

::operator new( sizeof( ) )

New operator :: type sizeof( type )

New sizeof( type ) operator

Scroll to Top