Question - When do you use :: Operator in C++?

Answer - :: is the scope resolution operator. When local variable and global variable are having same name, local variable gets the priority. C++ allows flexibility of accessing both the variables through a scope resolution operator.

Question - Define reference variable in C++.

Answer - A reference variable is just like pointer with few differences. It is declared using & operator. A reference variable must always be initialized. The reference variable once defined to refer to a variable can’t be changed to point to other variable. You can't create an array of references the way it is possible with pointer.

Question - What is const qualifier?

Answer - const qualifier is used to specify the variable that can’t be change throughout the program. Variable with const qualifier is often named in uppercase.

Question - When do you use bool data type?

Answer - The bool data type can take only two values true or false.

Question - What is function overloading in C++?

Answer - You can have multiple functions with same name using function overloading facility of C++. You can use same name for multiple functions when all these functions are doing same thing.

Question - What is operator overloading in C++?

Answer - With this facility in C++, you can give additional meaning to operators.


Question - Define Inline Function.

Answer - When the function is defined Inline, the C++ compiler puts the function body inside the calling function. You can define function as Inline when the function body is small and need to be called many times, thus reduces the overhead in calling a function like passing values, passing control, returning values, returning control.

Question - Define class using C++.

Answer - A class holds the data and functions that operate on the data. It serves as the template of an object.

Question - When do you use this pointer?

Answer - 'this pointer' is used as a pointer to the class object instance by the member function. The address of the class instance is passed as an implicit parameter to the member functions.

Question - What is new and delete operator?

Answer - In C++, when you want dynamic memory, you can use operator new. It returns a pointer to the beginning of the new block of memory allocated. It returns a pointer to the beginning of the new block of memory allocated.

When memory allocated by new operator is no longer required, it is freed using operator delete.

Question - Define local class in C++.

Answer - Local class is define within the scope of a function and nested within a function.
E.g.
int func1()
{
class localclass1
{.....};
}


Question - Define namespace in C++.

Answer - Namespaces groups together entities like classes, objects and functions under a name. Namespaces provide a way to avoid name collisions of variables, types, classes or functions. Namespaces reduces the use of nested class thus reduces the inconvenience of handling nested class.

Question - What is the default access level?

Answer - The access privileges in C++ are private, public and protected. The default access level assigned to members of a class is private. Private members of a class are accessible only within the class and by friends of the class. Protected members are accessible by the class itself and its sub- classes. Public members of a class can be accessed by anyone.

Question - Explain friend class in C++.

Answer - When a class declares another class as its friend, it is giving complete access to all its data and methods including private and protected data and methods to the friend class member methods. Friendship is one way only, which means if A declares B as its friend it does NOT mean that A can access private data of B. It only means that B can access all data of A.

Question - What is virtual function?

Answer - Virtual function is the member function of a class that can be overriden in its derived class. It is declared with virtual keyword. Virtual function call is resolved at run-time (dynamic binding) whereas the non-virtual member functions are resolved at compile time (static binding).

Question - Define default constructor.

Answer - Default constructor is the constructor with no arguments or all the arguments has default values.

Question - Define abstraction.

Answer - The process of hiding unnecessary data and exposing essential features is called abstraction. Abstraction is separating the logical properties from implementation details.

Question - What is overriding?

Answer - Defining a function in the derived class with same name as in the parent class is called overriding. In C++, the base class member can be overridden by the derived class function with the same signature as the base class function. Method overriding is used to provide different implementations of a function so that a more specific behavior can be realized.

Question - What is copy constructor?

Answer - A copy constructor is a special type of constructor that is used to create an object as a copy of an existing object. It takes an argument which is a reference to the object to be copied.


Previous Part 1 Next Part 3

These icons link to social bookmarking sites where readers can share and discover new web pages.
  • Digg
  • Sphinn
  • del.icio.us
  • Facebook
  • Mixx
  • Google
  • Furl
  • Reddit
  • Spurl
  • StumbleUpon
  • Technorati