LakshyaEducation.in

VEDIC MATHS Video Series
  • Home
  • Video Series
    • Vedic Maths Videos
    • Quantitative Aptitude Videos
    • Class 8 Maths Videos
    • Class 9 Maths Videos
    • Class 10 Maths Videos
  • Quiz & Solutions
  • Blog
  • Store
  • Login
  • Contact Us
  • Home
  • Topic
  • C++ Programming
  • Free Store

C++ Programming

FREE STORE MCQs

Total Questions : 10

Question 1.

How can object be allocated outside the object lifetime?


  1.    int
  2.    float
  3.    void*
  4.    None of the mentioned
 Discuss Question
Answer is Option C. -> void*

None.

Question 2.

What must be an operand of operator delete?


  1.    Pointer
  2.    Array
  3.    Stack
  4.    None of the mentioned
 Discuss Question
Answer is Option A. -> Pointer

The operand of delete must be a pointer returned by new.

Question 3.


What is the output of this program?



1.
#include
2.
#include
3.
#include
4.
using namespace std;
5.
const int bsize = 512;
6.
int *pa;
7.
bool allocate = true;
8.
void get_memory()
9.
{
10.
cerr
  1.    free store addr
  2.    Error
  3.    Segmentation fault
  4.    None of the mentioned
 Discuss Question
Answer is Option C. -> Segmentation fault

In this program, The memory will go beyond the limit, So there will be exhaustion in memory.
Output:
$ g++ free4.cpp
$ a.out
free store addr = 0x80a8008
Segmentation fault

Question 4.


What is the output of this program?



1.
#include
2.
#include
3.
#include
4.
using namespace std;
5.
class X;
6.
struct Node
7.
{
8.
X* data;
9.
bool filled;
10.
Node() : filled(false) { }
11.
};
12.
class X
13.
{
14.
static Node buffer[];
15.
public:
16.
int number;
17.
enum { size = 3};
18.
void* operator new(size_t sz) throw (const char*)
19.
{
20.
void* p = malloc(sz);
21.
if (sz == 0)
22.
throw "Error: malloc() failed";
23.
cout
  1.    X::operator new(size_t)
  2.    Error
  3.    Runtime error
  4.    None of the mentioned
 Discuss Question
Answer is Option C. -> Runtime error

In this program, We are giving a location to two variables in the program, So it is arising an exception.
Output:
$ g++ free3.cpp
$ a.out
X::operator new(size_t)
X::operator new(size_t, 0)
X::operator new(size_t, 1)
X::operator new(size_t, 2)
10000
10001
10002
X::operator new(size_t, 0)
Error: buffer location occupied

Question 5.


What is the output of this program?



1.
#include
2.
#include
3.
using namespace std;
4.
class X
5.
{
6.
public:
7.
void* operator new(size_t sz) throw (const char*)
8.
{
9.
void* p = malloc(sz);
10.
if (p == 0)
11.
throw "malloc() failed";
12.
return p;
13.
}
14.
void operator delete(void* p)
15.
{
16.
cout
  1.    X::operator delete(void*)
  2.    Freeing 400 bytes
  3.    Depends on the compiler
  4.    Both a & c
 Discuss Question
Answer is Option D. -> Both a & c

The memory value allocated for the program depends on compiler ony.
$ g++ free2.cpp
$ a.out
X :: operator delete(void*)
Freeing 400 bytes

Question 6.


What is the output of this program?



1.
#include
2.
using namespace std;
3.
struct A
4.
{
5.
virtual ~A()
6.
{
7.
cout
  1.    ~A()
  2.    A :: operator delete[]
  3.    B :: operator delete[]
  4.    Warning
 Discuss Question
Answer is Option D. -> Warning

In this program, the behavior of the statement delete[] bp is undefined.
$ g++ a.cpp
a.cpp: In static member function 'static void A::operator delete [](void*, size_t)':
a.cpp:12: warning: deleting 'void*' is undefined
a.cpp: In static member function 'static void B::operator delete [](void*, size_t)':
a.cpp:20: warning: deleting 'void*' is undefined

$ a.out
~A()
~A()
~A()
A :: operator delete[]

Question 7.

Which is used to allocate and deallocate storage for objects during the execution?


  1.    Stack
  2.    Heap
  3.    Freestore
  4.    None of the mentioned
 Discuss Question
Answer is Option C. -> Freestore

Free store is a pool of memory available for you to allocate and deallocate storage for objects 

during the execution of your program.

Question 8.

Which operators are used in the free store?


  1.    new
  2.    delete
  3.    Both a & b
  4.    None of the mentioned
 Discuss Question
Answer is Option C. -> Both a & b

new and delete operators is used to allocate and deallocate the memory for the program.

Question 9.

What type of class member is operator new?


  1.    static
  2.    dynamic
  3.    const
  4.    smart
 Discuss Question
Answer is Option A. -> static

None.

Question 10.


What is the output of this program?



1.
#include
2.
#include
3.
using namespace std;
4.
struct A
5.
{
6.
virtual ~A() { };
7.
void operator delete(void* p)
8.
{
9.
cout
  1.    A::operator delete
  2.    B::operator delete
  3.    Both a & b
  4.    None of the mentioned
 Discuss Question
Answer is Option B. -> B::operator delete

In this program, We are passing the value to the B, So we are printing B::operator delete.
Output:
$ g++ free.cpp
$ a.out
B::operator delete

  • Share on Facebook!
  • Share on Pinterest!

Sub Topics

  • Abstract Classes
  • Access Control
  • Argument Passing
  • Arrays
  • Booleans
  • C++ Concepts
  • Catching Exceptions
  • Character Types
  • Class Hierarchies And Abstract Classes
  • Class Hierarchies Introduction
  • Classes
  • Comments And Indentation
  • Complex Number Type
  • Constants
  • Constructors And Destructors
  • Container Design
  • Conversion Operators
  • Declaration
  • Default Arguments
  • Dereferencing
  • Derivation And Templates
  • Derived Classes
  • Design Of Class Hierarchies
  • Enumerations
  • Error Handling
  • Error Handling Alternatives
  • Essential Operators
  • Exception Specifications
  • Exceptions
  • Exceptions And Efficiency
  • Exceptions That Are Not Errors
  • Floating Point Types
  • Free Store
  • Friends
  • Function Call
  • Function Declarations
  • Function Templates
  • Functions
  • Grouping Of Exceptions
  • Header Files Usage
  • Increment And Decrement
  • Integer Types
  • Large Objects
  • Linkage
  • Macros
  • Modularization And Interfaces
  • Multiple Inheritance
  • Namespaces
  • Objects
  • Objects And Classes
  • Oops Concepts
  • Operator Functions
  • Operators
  • Overloaded Function Names
  • Pointer To Function
  • Pointer To Void
  • Pointers
  • Pointers Into Arrays
  • Pointers To Members
  • References
  • Resource Management
  • Run Time Type Information
  • Sequence Adapters
  • Sequences
  • Simple String Template
  • Sizes
  • Specialization
  • Standard Exceptions
  • Standard Library Design
  • Statements
  • String Class
  • Structures
  • Subscripting
  • Template Arguments To Specify Policy Usage
  • Types
  • Uncaught Exceptions
  • Unspecified Number Of Arguments
  • User Defined Types
  • Value Return
  • Vector
  • Void

Recent Posts

  • Vedic Maths Faq
  • Is Ssc Difficult Than Upsc?
  • Sail E0 Results 2022
  • Quantitative Aptitude Faqs
  • Ssc Exam Guide Book
  • Best Ssc Exam For Girls
  • Sail E0 Exam Results Cancelled - Exam Will Be Rescheduled

Recent Questions

Q.   Which State/UT Launched The 'Tourist Village Network' To Pro....

Q.   Which Of The Following Transaction Can Be Used To Create T-c....

Q.   Organizing Taxonomic Information In Logical Classification I....

Q.   Rolling Friction Is Caused By ________

Q.   A Stone Is Whirled In A Vertical Circle, The Tension In The ....

Q.   In A Tropical Year, The Number Of Sidereal Days, Are

Q.   Synonym Of UNIFORMITY

Q.   Statement: It Is Estimated That About Twenty Lakh People Wi....

Q.   Which Logic Gates Output A 1 If Their Inputs Are 0 And 1?

Q.   An Action Potential Is Caused By An Influx Of _____ Ions Int....

Q.   Force Exerted By Magnetic Field In Hall Effect Transducers I....

Q.   The Factors Which Are To Be Considered While Developing A Go....

Q.   Blood Group Which Have No Antigen

Q.   Threshold Limit Value Of Copper In The Atmospheric Air Is

Q.   When Libya Gave Up Its Nuclear Program?

Q.   How Much Amount Has Been Extended By The EXIM Bank As The Li....

Q.   A Second Order System Exhibits 100% Overshoot. The Damping R....

Q.   Which Are The Special Tags Used For Image Mapping?

Q.   Indict

Q.   Two Perfectly Elastic Spheres Of Equal Mass Moving In The ....

Topics

Computer Aptitude
SAIL Junior Officer (E-0)
10th Grade
11th Grade
12th Grade
4th Grade
5th Grade
6th Grade
7th Grade
8th Grade
9th Grade
NCERT
Cat
Commerce
Computer Science
Engineering
English
General Knowledge
Ias
Management
Quantitative Aptitude
Reasoning Aptitude
General Studies (Finance And Economics)
Vedic Maths
Analytical Instrumentation
Biochemistry
Bioinformatics
Biology
Biotechnology
Bitsat
Business Statistics
C Programming
C++ Programming
Cell Biology
Chemistry
Cost Accounting
Drug And Pharmaceutical Biotechnology
Electrical Measurement And Instrumentation
Environment Management
Environmental Biotechnology
Enzyme Technology
Financial Management And Financial Markets
Gate
General Science
Geography
Heat Transfer
History And National Movements
Human Anatomy And Physiology
Human And Cultural Diversity
Human Resource Management
Indian Economy
Indian Geography
Indian History
Indian Polity
Instrumentation Transducers
International Relations
Life Sciences
Marketing And Marketing Management
Mass Transfer
Mechanics Of Materials
Microbiology
Neet
Professional Communication
Renewable Energy
Sociology
Surveying
Total Quality Management
Uidai Aadhaar Supervisor Certification
Virology
LakshyaEducation.in
Lakshya Education
Bhilai,Chattisgarh,India
Email: admin@lakshyaeducation.in Phone: 07893519977 (WhatsApp)

Quick Links

  • Vedic Maths
  • Quantitative Aptitude
  • Class – IX Maths
  • Class – X Maths
  • Blog

Our Services

  • About us
  • Privacy
  • TOS
  • Refund / Cancellation
  • Contact
  • Affiliate Program
  • Copyright © 2022 All Right Reserved | Lakshya Education     ( )
    Login / Register

    Your Account will be created automatically when you click the below Google or Facebook Login Button.
    •   Login With Facebook
    •  Login With Google
     Login With Email/Password