Prepare Interview

Mock Exams

Make Homepage

Bookmark this page

Subscribe Email Address

C++ Interview Questions and Answers

Test your skills through the online practice test: C++ Quiz Online Practice Test

Related differences

C vs C++Java vs C++

Ques 46. What do you mean by pure virtual functions?


A pure virtual member function is a member function that the base class forces derived classes to provide. Normally these member functions have no implementation. Pure virtual functions are equated to zero.
class Shape { public: virtual void draw() = 0; };

Is it helpful? Add Comment View Comments
 

Ques 47. What is polymorphism? Explain with an example?


"Poly" means "many" and "morph" means "form". Polymorphism is the ability of an object (or reference) to assume (be replaced by) or become many different forms of object.
Example: function overloading, function overriding, virtual functions. Another example can be a plus ?+? sign, used for adding two integers or for using it to concatenate two strings.

Is it helpful? Add Comment View Comments
 

Ques 48. What?s the output of the following program? Why?

#include <stdio.h>
main()
{
typedef union
{
int a;
char b[10];
float c;
}
Union;

Union x,y = {100};
x.a = 50;
strcpy(x.b,"hello");
x.c = 21.50;

printf("Union x : %d %s %f n",x.a,x.b,x.c );
printf("Union y :%d %s%f n",y.a,y.b,y.c);
}

Given inputs X, Y, Z and operations | and & (meaning bitwise OR and AND, respectively)
What is output equal to in
output = (X & Y) | (X & Z) | (Y & Z)

Is it helpful? Add Comment View Comments
 

Ques 49. Why are arrays usually processed with for loop?


The real power of arrays comes from their facility of using an index variable to traverse the array, accessing each element with the same expression a[i]. All the is needed to make this work is a iterated statement in which the variable i serves as a counter, incrementing from 0 to a.length -1. That is exactly what a loop does.

Is it helpful? Add Comment View Comments
 

Ques 50. What is an HTML tag?


Answer: An HTML tag is a syntactical construct in the HTML language that abbreviates specific instructions to be executed when the HTML script is loaded into a Web browser. It is like a method in Java, a function in C++, a procedure in Pascal, or a subroutine in FORTRAN.

Is it helpful? Add Comment View Comments
 

4) Why are arrays usually processed with for loop? 5) What is an HTML tag? " />

Most helpful rated by users:

©2024 WithoutBook