Sunday, January 13, 2013

C++ Interview questions and answers Part-01


C++ Interview questions and answers Part-01

Define structured programming.

Structured programming techniques use functions or subroutines to organize the programming code. The programming purpose is broken into smaller pieces and organized together using function. This technique provides cleaner code and simplifies maintaining the program. Each function has its own identity and isolated from other, thus change in one function doesn’t affect other

Explain Object oriented programming.

Object oriented programming uses objects to design applications. This technique is designed to isolate data. The data and the functions that operate on the data are combined into single unit. This unit is called an object. Each object can have properties and member functions. You can call member function to access data of an object. It is based on several techniques like
encapsulation, modularity, polymorphism, and inheritance
List down elements of an object oriented language. Class
A class is a user defined data type. It serves as a template of the objects. You can define
structure and behavior of an object using class. It includes data and the member functions that
operate on data

Inheritance
Inheritance enables a new class to reuse the state and behavior of old class. The new class inherits properties and methods from the old class and is called as derived class and the old class is called as base class. The methods thus inherited can be extended using overriding facility of C++

Encapsulation
The wrapping up of data and member function into an object is called encapsulation. The data is not accessible to the outside world and only those functions which are wrapped into the object can access it. An encapsulated objects act as a "black box" for other parts of the program which
interact with it. They provide a service, but the calling objects do not need to know the details how
the service is accomplished

Polymorphism
Polymorphism enables one common interface for many implementations that allows objects to act differently under different circumstances. You can also achieve polymorphism in C++ by function overloading, operator overloading and implementation inheritance

What is function prototype in C++?

A function prototype is a declaration of a function that omits the function body. It specifies the
function's name, argument types and return type. E.g. int add(int,int) 
Define Structure in C++.

The C++ programming technique allows defining user defined datatypes through structure. The
syntax to declare structure is as follows

struct student
{
      char name[100]
      char address[250]
};

Explain typecasting.

Typecasting enables data type conversion. C++ supports implicit conversions and explicit conversion. Implicit conversions automatically performed when a value is copied to a compatible type. If there is an operation between an int and a float, the int is promoted to float before performing operation automatically by the compiler. 
You can cast explicitly as follows
int i, j, k;  
k = i * long(j)

Define void pointer using C++.

In C++, void represents the absence of type, so void pointers are pointers that point to a value
that has no type. The void pointers can point to any data type. You can declare void pointer as follows.
void *p;

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

:: 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

Define reference variable in C++.

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.

What is const qualifier?

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

Please Share it! :)

Ditulis Oleh : Nangraj Hari: 4:35 AM Kategori:

0 comments:

Post a Comment

 
PLEASE VISIT MY OTHER BLOG TO DOWNLOAD LATEST FULL CRACKED SOFTWARES,GAMES,COMPUTER NOTES,VIDEO TUTORIALS,AND MUCH MORECLICK HERE