Select chapter



constructors (2.papers)
inheritance (1.papers)
overriding (1.papers)
basics (4.papers)
pointers (2.papers)
Hide

Sponsored Links


  

c++ basics interview questions and answers

Show Answer
Share Facebook gmail Twitter
2
Does c++ has global variable concept?
  1. In c++ there is no global variable concept.
  2. c++ also has global variable concept just like c.
  3. c has global variables but c++ doesn't
  4. c++ has global variables but c doesn't.
Show Answer
Share Facebook gmail Twitter
3
What is the use of assignment operator in c++, when used with objects of same class?
  1. it copies the address of one object to other object.
  2. it copies the whole contents of one object to other object. Shallow copy only.
  3. it copies the whole contents of one object to other object. Deep copy.
  4. it does all the 3.
Show Answer
Share Facebook gmail Twitter
4
How to access static members of a class?
  1. by using object and dot operator
  2. by using dot operator (.)
  3. by using scope resolution operator (::)
  4. none
Show Answer
Share Facebook gmail Twitter
5
How many copies of a static variable will exist in memory?
  1. it depends on how many number of objects you are creating for that class. That many copies will be there.
  2. No matter how many objects you create for that class, only one copy of static variable will be created.
  3. 0 copies
  4. none
Show Answer
Share Facebook gmail Twitter
6
When static variables will be allocated memory and created?
  1. when we create first object for that class, then all the static variables will be allocated and created.
  2. Before creating any object for that class, at the time of class loading time, static variables will be allocated and created.
  3. we can't really predict
  4. none
Show Answer
Share Facebook gmail Twitter
7
What is the output of below C++ program?
class Base{
    public:
    static int si;
};

    int Base::si;

int main()
{
    Base::si = 101;
    cout<<Base::si;
}
  1. 0
  2. compile time error, we can't access variable si, with out creating object for that class.
  3. garbage
  4. 101
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
9
What is the use of static variables in c++?
  1. if you want to create a variable only once for an object, then use static variables.
  2. there is no use case as such, and more over it is quite confusing and error prone to use static variables.
  3. if you want to share a common variable among all the objects of same class then use static variable.
  4. none
Show Answer
Share Facebook gmail Twitter
10
What is the use of a static function in c++?
  1. you can use it to access only other static members of that class.
  2. you can access instance members of a class using static methods, without creating object for that class.
  3. you can access only static variables from a static method.
  4. there is no static method concept in c++
Show Answer
Share Facebook gmail Twitter
11
Can I call a static functions also directly by using class name?
  1. no, it is applicable only for static variables, using :: operator
  2. yes, you can call any static member of a class by using class name and :: operator.
  3. can't say
  4. none
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
13
In the below program how to access global variable i?
int i=10;

int main()
{
   int i=20;
   cout<<i;
}
  1. no way
  2. you can do it. remove local variable i=20;
  3. first of all this program gives compile time error.
  4. use ::i
Show Answer
Share Facebook gmail Twitter
14
What is polymorphism?
  1. Any thing that is having more than one form is called as polymorphism.
  2. Base class object's executing functions of derived class at run time, is one kind of polymorphism.
  3. both option 1 & 2 are true
  4. none
Show Answer
Share Facebook gmail Twitter
15
What is encapsulation?
  1. wrapping of data and functions in such a way that, it will hide the internal information or implementation details.
  2. Encapsulation is a mechanism to achieve data security by making them private.
  3. both option 1 & 2 are true
  4. none
Show Answer
Share Facebook gmail Twitter
16
What is the difference between c, c++ in terms of programming?
  1. c++ has classes, and c doesn't. c++ is object oriented and c is not.
  2. in c++ you have to write everything in class, where as in c there is no restriction.
  3. c++ don't have global variables where as c has.
  4. all are true
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
18
What is the difference between c & c++, in terms of project maintenance?
  1. project maintenance time is more in c, and less in c++.
  2. project maintenance time is less in c, and more in c++.
  3. you can't simply claim like that, it depends.
Show Answer
Share Facebook gmail Twitter
Show Answer
Share Facebook gmail Twitter
20
What is the difference between c, c++ in terms of pointers?
  1. there is no difference.
  2. c++ has references along with pointers. Where as c have only pointers.
  3. c has references where c++ doesn't have.
  4. both c, c++ has pointers as well as references.
Show Answer
Share Facebook gmail Twitter
Read more papers :