Vidyalelo
C++ Programming · all questions

Introduction to C++
practice.

Practice every MCQ with options. Use Show answers when you want the correct option and solution.

138

Questions

7/7

Page

Pick an option on a question to see the right answer and solution.

What are the actual parameters in C++?

Select an option to see the answer and solution.

What will be the output of the following C++ code?
#include<stdio.h>
int main(int argc, char const *argv[])
{
	char a = 'a';
	printf("%d\n", (int)sizeof(a));
	return 0;
}

Select an option to see the answer and solution.

Which of the following is used to make an abstract class?

Select an option to see the answer and solution.

Which of the following supports the concept that reusability is a desirable feature of a language?

Select an option to see the answer and solution.

What will be the output of the following C++ code?
#include<iostream>
using namespace std;
int main ()
{
   int cin;
   cin >> cin;
   cout << "cin: " << cin;
   return 0;
}

Select an option to see the answer and solution.

What happens if the following line is executed in C and C++?
int *p = malloc(10);

Select an option to see the answer and solution.

Which of the following is C++ equivalent for printf()?

Select an option to see the answer and solution.

Which of the following is correct?

Select an option to see the answer and solution.

Which of the following statement is true?
I. In Procedural programming languages, all function calls are resolved at compile-time
II. In Object Oriented programming languages, all function calls are resolved at compile-time

Select an option to see the answer and solution.

Which of the following is correct about dynamic polymorphism?

Select an option to see the answer and solution.

Which operator is overloaded for a cout object?

Select an option to see the answer and solution.

Which members are inherited but are not accessible in any case?

Select an option to see the answer and solution.

What happens if we run the following code in both C and C++?
#include<stdio.h>
struct STRUCT
{
  int a;
  int func()
  {
      printf("HELLO THIS IS STRUCTURE\n");
  }
};
int main()
{
  struct STRUCT s;
  s.func();
  return 0;
}

Select an option to see the answer and solution.

What happens if the following code is compiled on both C and C++?
#include<stdio.h>
struct STRUCT
{
private:
	int a;
};
int main()
{
	printf("%d\n", (int)sizeof(struct STRUCT));
	return 0;
}

Select an option to see the answer and solution.

What happens if the following program is executed in C and C++?
#include <stdio.h> 
int main(void) 
{ 
	const int j = 20; 
	int *ptr = &j;
	printf("*ptr: %d\n", *ptr); 
	return 0; 
}

Select an option to see the answer and solution.

Which of the following C++ code will give error on compilation?
================code 1=================
#include <iostream>
using namespace std;
int main(int argc, char const *argv[])
{
	cout<<"Hello World";
	return 0;
}
========================================
================code 2=================
#include <iostream>
int main(int argc, char const *argv[])
{
	std::cout<<"Hello World";
	return 0;
}
========================================

Select an option to see the answer and solution.

What will be the output of the following C++ code?
#include <stdio.h>
int main()
{
   const int x;
   x = 10;
   printf("%d", x);
   return 0;
}

Select an option to see the answer and solution.

In which part of the for loop termination condition is checked?
for(I;II;III)
{IV}

Select an option to see the answer and solution.