You are on page 1of 8

C++ Important Interview Question & Answers

1.The operator >> is called Ans.a get from operator 2.What Is the default access specifier? Ans.private 3.C++ is an Ans.object oriented programming Language 4.Which provides support for simultaneous input and output operations Ans.Fstream 5.Predict The Output Of the Following class base { public: int bval; base(){ bval=0;} }; class deri:public base { public: int dval; deri(){ dval=1;} }; void SomeFunc(base *arr,int size) { for(int i=0; i cout<bval; cout<} int main() { base BaseArr[5];
For Freshers Jobs Visit @ www.latestoffcampus.com //And For Interview Questions Visit @www.blog.latestoffcampus.com //Experienced Jobs @ www.latestoffcampus.com/jobs

SomeFunc(BaseArr,5); deri DeriArr[5]; SomeFunc(DeriArr,5); } Ans.


00000 01010

6.Which keyword is Used by C++ to represent an object that invokes a member function Ans. this 7.Which Sort Uses the binary tree concept such that any number is larger than all the numbers in the Subtree Ans. Heap 8.The number of passes required for sorting M records of length N using simple external sorting algorithm is Ans. (A) [log(N/M)] 9.A binary search tree contains the values - 1,2,3,4,5,6,7,8. The tree is traversed in preorder and the values are printed out. What is The valid output? Ans. 5 3 1 2 10.The wrapping up of data and functions into a single unit is known as Ans. encapsulation 11.What are the basic run-time entities in an object oriented system Ans. Objects 12.Field width operator is Ans. setw 13.What is the function that is expanded in line when it is invoked Ans. inline function 14.Variables declared inside the class are known as Ans. datamembers 15.Dynamic allocation operator in C++ is Ans. new
For Freshers Jobs Visit @ www.latestoffcampus.com //And For Interview Questions Visit @www.blog.latestoffcampus.com //Experienced Jobs @ www.latestoffcampus.com/jobs

16.What Is the output of the following main() { int x=20,y=35; x = y++ + x++; y = ++y + ++x; printf("%d %d\n",x,y); } Ans. 57 94 17.Pointer to member operator is Ans. .* 18.What is the order of the binary search algorithm? Ans. log n 19.In a binary search tree if the key element is less than the root element then sub tree must be searched in Ans. left 20.Find Out The output Of the following #include main() { char *p1; char *p2; p1=(char *) malloc(25); p2=(char *) malloc(25); strcpy(p1,"Latest"); strcpy(p2,"Offcampus"); strcat(p1,p2); printf("%s",p1); } Ans. LatestOffcampus 21.Which operation is used to add an item in a queue Ans.write()

For Freshers Jobs Visit @ www.latestoffcampus.com //And For Interview Questions Visit @www.blog.latestoffcampus.com //Experienced Jobs @ www.latestoffcampus.com/jobs

22.Queue can be used to implement Ans.radix sort 23.The average number of comparisons performed by the merge sort algorithm , in merging two sorted lists of length 2 is Ans.8/3 24.What are the output(s) for the following ? #define MAN(x,y) (x)>(y)?(x):(y) {int i=10; j=5; k=0; k=MAX(i++,++j); printf(%d %d %d %d,i,j,k); } Ans . 10 5 0 25.The Object is not declared for which class? Ans. Abstract 26.Data that consists of a single, non decomposable entity are known Ans. atomic data 27.In how many ways is polymorphism achived in C++? Ans. 3 28.In Data members is also called? Ans. Attribute 29.What is the sum of degrees of all the nodes In an undirected graph Ans.must be even 30.In which trie node allows only one character Ans. compressed 31.What is the output of the following void main() { int i; for(i=1;i<4,i++) switch(i)
For Freshers Jobs Visit @ www.latestoffcampus.com //And For Interview Questions Visit @www.blog.latestoffcampus.com //Experienced Jobs @ www.latestoffcampus.com/jobs

case 1: printf("%d",i);break; { case 2:printf("%d",i);break; case 3:printf("%d",i);break; } switch(i) case 4:printf("%d",i); } Ans. 1,2,3,4 32.A priority queue is an abstract concept like a Ans. list or map 33.How Many no.of comparisons Required For merging two sorted lists of sizes m and n into a sorted list of size m+n Ans. O(m+n) 34.Which strategy is used by the merge sort Ans. divide and conquer 35.What is the depth of a complete binary tree with n nodes Ans. log2(n+1)-1 36.Which tree is a self-balancing binary search tree Ans. AVL 37.What is the minimum number of edges in a connected cyclic on n vertices? Ans. n 38.An n vertex undirected graph with exactly n*(n-1)/2 edges is said to be Ans.Complete graph 39.A Standard Tree Uses Ans. O(n) Spces 40.The goal of operator overloading is Ans.To help the user of a class 41.Which is a special method used to initialize the instance variable of a class. Ans.Constructor

For Freshers Jobs Visit @ www.latestoffcampus.com //And For Interview Questions Visit @www.blog.latestoffcampus.com //Experienced Jobs @ www.latestoffcampus.com/jobs

42.Access to private data Means? Ans.Restricted to methods of other classes 43.The static member variable is initialized to? Ans. 0 44.What will be the output of following program #include<iostream.h> void main() { float x; x=(float)9/2; cout<<x; } Ans. 4.5 44.Usually a pure Virtual Function is Ans. Is defined only in derived class 45.A Class can have how many destructor? Ans.1 46.The process of extracting the relevant attributes of an object is known as Ans. Inheritance 47.Which diagram provides a formal graphic notation for modelling objects, classes and their relationships to one another? Ans. Object Diagram 48.Which data structure allows deleting data elements from front and inserting at rear? Ans.Queues 49.The post order traversal of a binary tree is DEBFCA. find out the pre order traversal Ans.ABDECF 50.Which constructor function is designed to copy objects of the same class type? Ans. Copy constructor

For Freshers Jobs Visit @ www.latestoffcampus.com //And For Interview Questions Visit @www.blog.latestoffcampus.com //Experienced Jobs @ www.latestoffcampus.com/jobs

51.What is mechanism Which binds code and data together and keeps them secure from outside world is? Ans.Encapsulation 52.Exception handling is targeted at Ans. Run-time error 53.Which keyword is used to make the class friend Ans.Friend 54.Where the default value of parameter have to be specified? Ans.Function prototype 55.C++ was developed by Ans. Bjame Stroustrup 56.Which operator that cannot be overloaded is? Ans. : : 57. What is the operator which is NOT used with pointers Ans. >> 58.For Which purpose we use constructor? Ans.Initialization 59.What is the operator which can be overloaded through friend function Ans. * 60.A class defined with in another class is Ans. Nested class

For Freshers Jobs Visit @ www.latestoffcampus.com //And For Interview Questions Visit @www.blog.latestoffcampus.com //Experienced Jobs @ www.latestoffcampus.com/jobs

For Freshers Jobs Visit @ www.latestoffcampus.com //And For Interview Questions Visit @www.blog.latestoffcampus.com //Experienced Jobs @ www.latestoffcampus.com/jobs

You might also like