Quick links
Latest articles
Internship
Members
New...
Algorithms
Discrete Mathematics
Big data
Languages
C
C++
C++ STL
Java
Data Structure
C#.Net
Android
Kotlin
SQL
Web
PHP
Python
JavaScript
CSS
Ajax
Node.js
Web prog.
Programs
C
C++
DS
Java
C#
Python
Aptitude
C
C++
Java
DBMS
Interview
C
Embedded C
Java
SEO
HR
CS Subjects
CS Basics
O.S.
Networks
DBMS
Embedded Systems
Cloud Computing
Machine learning
CS Organizations
Linux
DOS
More...
Articles
Puzzles
News/Updates

Home » C++ Quiz Questions

C++ new and delete operators quiz



This section contains C++ new and delete operators quiz questions and answers with explanations.
Submitted by IncludeHelp, on May 22, 2018

Question 1
What is the correct syntax to declare an integer variable dynamically in C++ programming language?

  1. int *ival = new int (10);
  2. int ival = new int (10);
  3. Both (A) and (B)
  4. None of these

View Answer | Explanation and Discussion


Question 2
What will be the output of the following program?

#include <iostream>
using namespace std;

int main() 
{
	int *ival = new int (10);
	
	cout<<ival<<endl;
	
	return 0;
}
  1. 10
  2. 0
  3. Memory address
  4. None of these

View Answer | Explanation and Discussion


Question 3
Which statement is trust about new operator in C++?

  1. new is an operator which calls the constructor also
  2. new allocates memory at run time and assigns newly allocated memory block’s memory too the pointer
  3. After allocating the memory new operators returns the pointer of the same type
  1. (1) and (2)
  2. (1) and (3)
  3. (2) and (3)
  4. All - (1), (2) and (3)

View Answer | Explanation and Discussion


Question 4
What is the output of the following program?

#include <iostream>
using namespace std;

class sample
{
    public:
	sample()
	{
		cout<<"Hi ";
	}
	~sample()
	{
		cout<<"Bye ";
	}
};

int main() 
{
	sample *obj = new sample();
	delete(obj);
	return 0;
}
  1. Hi Bye
  2. Hi
  3. Bye
  4. No output

View Answer | Explanation and Discussion







Quick links:
C FAQ(s) C Advance programs C/C++ Tips & Tricks Puzzles JavaScript CSS Python Linux Commands PHP Android Articles More...

Featured post:
Introduction to Linux (Its modes, Safety, Most popular Applications)
Linux Best Distribution Software (Distros) of 2018

Was this page helpful? Please share with your friends...

Are you a blogger? Join our Blogging forum.

Comments and Discussions



Languages: » C » C++ » C++ STL » Java » Data Structure » C#.Net » Android » Kotlin » SQL
Web Technologies: » PHP » Python » JavaScript » CSS » Ajax » Node.js » Web programming/HTML
Solved programs: » C » C++ » DS » Java » C#
Aptitude que. & ans.: » C » C++ » Java » DBMS
Interview que. & ans.: » C » Embedded C » Java » SEO » HR
CS Subjects: » CS Basics » O.S. » Networks » DBMS » Embedded Systems » Cloud Computing » Machine learning » CS Organizations » Linux » DOS
More: » Articles » Puzzles » News/Updates


© https://www.includehelp.com (2015-2018), Some rights reserved.