Wednesday, March 7, 2018

C++ Viva Voce Questions


Local Variables:    
Variables that are declared inside a function or block are local variables. They can be used only by statements that are inside that function or block of code. 

Global Variables:   
Global variables are defined outside of all the functions, usually on top of the program. 


New operator:
The new operator denotes a request for memory allocation on the Heap. If sufficient memory is available, new operator initializes the memory and returns the address of the newly allocated and initialized memory to the pointer variable.
·         Syntax to use new operator: pointer.variable= new data type

Delete operator:
It is programmer’s responsibility to deallocate dynamically allocated memory, programmers are provided delete operator by C++ language.
·         Syntax : delete pointer_variable


Scope resolution operator:
Scope resolution operator (::) in C++ programming language is used to define a function outside a class or when we want to use a global variable but also has a local variable with the same name.

Enumerations:
Enumeration (or enum) is a user defined data type in C. It is mainly used to assign names to integral constants, the names make a program easy to read and maintain.
·         Syntax:  Enum enum_name{list of names} var-list;

Objects:       
Objects are primary run-time entities in object-oriented programming.

Classes:
A class is a grouping of objects that have the identical properties, common behavior, and shared relationship. A class binds the data and its related functions together.
                         
Method:      
An operation required for an object or entity when coded in a class is called a method.
   

Abstraction:
Data abstraction refers to, providing only essential information to the outside world and hiding the background details.


Encapsulation:            
Encapsulation is placing the data and the functions that work on that data in the same place.


Inheritance:           
The method by which objects of one class get the properties of objects of another class.


Polymorphism:    
Polymorphism allows the same function to act in different ways in different classes.

Dynamic Binding:           
Binding refers to the linking of one program to another program that is to be executed in response to the call.

Message Passing: 
A message of an object is request for execution of a procedure. And therefore will invoke a procedure (function) and gives desired result.

Reusability:
Object Oriented Programming allows reusability of the classes by extending them to other classes using inheritance.

Delegation:
When object of one class is used as data member in the other class, such composition of         objects is known as delegation.

Genericity:
The programmer can create a function that can be use for any type of data. The template feature in C++ allows generic programming.

Instantiation:
Defining objects of class data type is known as class instantiation.




Access Specifiers:
Access specifiers are used to set boundaries for availability of members of class be it data members or member functions

Public
Keyword:         The data members and member functions declared public can be accessed by  
                        other classes.



Private Keyword:
No one can access the class members declared private outside that class. By default class variables and member functions are private.



Protected Keyword:       
Protected, is the last access specifier, and it is similar to private, it makes class member inaccessible outside the class. But they can be accessed by any subclass of that class.

c++.PNG

Member Function:          
A member function of a class is a function that has its definition or its prototype within the class definition like any other variable.

Constructors:
A class constructor is a special function in a class that is called when a new object of new object of the class is created.

Destructors:          
A destructor is also a special function which is called when created object is deleted.

Copy Constructors:        
The copy constructor is a constructor which creates an object by  initializing it with an object of the same class, which has been created previously.
Friend Function: 
A friend function of a class is defined outside that class' scope but it has the right to access all private and protected members of the class. 

Inline Function:   
With an inline function, the compiler tries to expand the code in the body of the function in place of a call to the function.

This Pointer:         
Every object in C++ has access to its own address through an important pointer called this pointer. The this pointer is an implicit parameter to all member functions. 


lvalue:          
Expressions that refer to a memory location is called "lvalue" expression. An lvalue may appear as either the left-hand or right-hand side of an assignment.
rvalue:         
The term rvalue refers to a data value that is stored at some address in memory. An rvalue is an expression that cannot have a value assigned to it which means an rvalue may appear on the right- but not left-hand side of an assignment.

Function Overloading:  
Defining  multiple function with same name in the same scope is called function overloading. The definition of the function must differ from each other by the types and/or the number of arguments in the argument list.

Operators Overloading:  
A programmer can use operators with user-defined types as well.
Overloaded operators are functions with special names:
the keyword "operator" followed by the symbol for the operator being defined. 

Unary Operators:
The unary operators operate on a single operand and following are the examples of Unary operators −
The unary minus (-) operator.
The logical not (!) operator.
The unary operators operate on the object for which they were called and normally, this operator appears on the left side of the object, as in !obj, -obj, and ++obj but sometime they can be used as postfix as well like obj++ or obj--.




Binary Operators:           
The binary operators take two arguments and following are the examples of Binary operators: addition (+) operator, subtraction (-) operator and division (/) operator.

Assignment Operator Overloading: 
The assignment operator can be overloaded (=) just as can other operators and it can be used to create an object just like the copy constructor.

Function Call Operator () Overloading:     
The function call operator () can be overloaded for objects of class type.

Virtual Function:
virtual function is a function in a base class that is declared using the keyword virtual. Defining in a base class a virtual function, with another version in a derived class, signals to the compiler that we don't want static linkage for this function.

Virtual Base Class:                      
When two or more objects are derived from a common base class, preventing of multiple copies of the base class being present in an object derived from those objects by declaring the base class as virtual when it is being inherited. Such a base class is known as virtual base class. 

Abstract Class:                  
An abstract class is a class that is declared abstract. Abstract classes cannot be instantiated, but they can be sub classed.

Static storage class:                     
This storage class is used to declare static variables which are popularly used while writing programs in C language. Static variables have a property of preserving their value even after they are out of their scope

Extern storage class simply tells us that the variable is defined elsewhere and not within the same block where it is used.

Inheritance:            
The method by which objects of one class get the properties of objects of another class.

Single Inheritance :
When only one class is derived from a single base class, such a derivation is known as single inheritance.


Multiple Inheritance:
 When two or more base classes are used for the derivation of a class, it is called multiple inheritance. 

Hierarchical Inheritance:
When a single base class is used for the derivation of two or more classes, it is known as Hierarchical Inheritance.

Multilevel Inheritance: 
When a class is derived from another derived class, that is, the derived  Class acts as base class, such a type of inheritance is known as multi level inheritance.

Hybrid Inheritance:
 A combination of one or more types of inheritance is known as  hybrid inheritance. 

Pointer:
pointer is a variable whose value is the address of another variable.

The NULL pointer is a constant with a value of zero defined in several standard libraries, including iostream.

Pointer Arithmetic :                    
Four arithmetic operators that can be used on pointers: ++, --, +, and -


Pointer To Pointer:                     
The first pointer contains the address of the second pointer, which points to the location that contains the actual value

Exception Handling:
An exception is a problem that arises during the execution of a program.

Throw − A program throws an exception when a problem shows up. This is done using a throw keyword.
Catch − A program catches an exception with an exception handler at the place in a program where you want to handle the problem. The catch keyword indicates the catching of an exception.
Try − A try block identifies a block of code for which particular exceptions will be activated. It's followed by one or more catch blocks.


Labels:

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home