1. What is C++?
Ans: C++ is created by Bjarne Stroustrup of AT&T Bell Labs as an extension of C, C++ is an object-oriented computer language used in the development of enterprise and commercial applications. Microsoft’s Visual C++ became the premier language of choice among developers and programmers.
2. What are the basic concepts of object oriented programming?
Ans: It is necessary to understand some of the concepts used extensively in object oriented programming.These include:
- Objects
- Classes
- Data abstraction and encapsulation
- Inheritance
- Polymorphism
- Dynamic Binding
- Message passing
3. Define inheritance?
Ans: The mechanism of deriving a new class (derived) from an old class (base class) is called inheritance. It allows the extension and reuse of existing code without having to rewrite the code from scratch. Inheritance is the process by which objects of one class acquire properties of objects of another class.
4. Define polymorphism?
Ans: Polymorphism means one name, multiple forms. It allows us to have more than one function with the same name in a program.It allows us to have overloading of operators so that an operation can exhibit different behaviours in different instances.
5. What are the features of C++ different from C?
Ans:
- All the features of C are similiar to C++ except some features, such as polymorphism, operator overloading which are supported in C++ but not in C language.
- Both C and C++ language is similiar in their functionality but C++ provides with more tools and options.
6. What is encapsulation?
Ans: The wrapping up of data and functions into a single unit (called class) is known as encapsulation. Encapsulation containing and hiding information about an object, such as internal data structures and code.
7. What is message passing?
Ans: An object oriented program consists of a set of objects that communicate with each other. Message passing involves specifying the name of the object, the name of the function and the information to be sent.
8. What are tokens in C++?
Ans: The smallest individual units of a program is known as tokens. c++ has the following tokens :
- Keywords
- Identifiers
- Constants
- Strings
- Operators
9. What is the use of enumerated data type?
Ans: An enumerated data type is another user defined type which provides a way for attaching names to numbers thereby increasing comprehensibility of the code. The enum keyword automatically enumerates a list of words by assigning them values 0,1,2, and so on.
10. What is the use of default constructor?
Ans: A constructors that accepts no parameters is called the default constructor.If no user-defined constructor exists for a class A and one is needed, the compiler implicitly declares a default parameterless constructor A::A(). This constructor is an inline public member of its class. The compiler will implicitly define A::A() when the compiler uses this constructor to create an object of type A. The constructor will have no constructor initializer and a null body.
11. Define Constructors?
Ans: A constructor is a member function with the same name as its class. The constructor is invoked whenever an object of its associated class is created.It is called constructor because it constructs the values of data members of the class.
12. How variable declaration in c++ differs that in c?
Ans: C requires all the variables to be declared at the beginning of a scope but in c++ we can declare variables anywhere in the scope. This makes the programmer easier to understand because the variables are declared in the context of their use.
13. Define destuctors?
Ans:
- A destructor is called for a class object when that object passes out of scope or is explicitly deleted.
- A destructors as the name implies is used to destroy the objects that have been created by a constructors.
- Like a constructor , the destructor is a member function whose name is the same as the class name but is precided by a tilde.
14. What is a class?
Ans: A class is a collection of objects.
15. what is the difference between c & c++?
Ans:
- C++ ia an object oriented programing but C is a procedure oriented programing.
- C is super set of C++.
- C can’t suport inheritance, function overloading, method overloading etc. but c++ can do this.
- In c program the main function could not return a value but in the c++ the main function shuld return a value.
16. What are the few advantages of Inline function?
Ans:
- It offers an improved macro facility.
- By using the inline functions, the user can split a large function with many nested modules of statement blocks into many small inline functions.
17. What is copy constructor?
Ans: Copy constructor is a constructor function with the same name as the class and used to make deep copy of objects.
18. What is default constructor?
Ans: A default constructor is a constructor that either has no parameters, or if it has parameters, all the parameters have default values.
19. What is a scope resolution operator?
Ans: The scope resolution operator permits a program to reference an identifier in the global scope that has been hidden by another identifier with the same name in the local scope.
20. What is the difference between Object and Instance?
Ans:
- An instance of a user-defined type is called an object. We can instantiate many objects from one class.
- An object is an instance of a class.
21. What is the difference between macro and inline?
Ans: Inline follows strict parameter type checking, macros do not.
Macros are always expanded by preprocessor, whereas compiler may or may not replace the inline definitions.
22. How variable declaration in c++ differs that in c?
Ans: C requires all the variables to be declared at the beginning of a scope but in c++ we can declare variables anywhere in the scope. This makes the programmer easier to understand because the variables are declared in the context of their use.
23. What is multiple inheritance?
Ans: A class can inherit properties from more than one class which is known as multiple inheritance.
24. what is the use of virtual destructor in c++?
Ans:
- A destructor is automatically called when the object is destroyed.
- A virtual destructor in C++ is used primarily to prevent resource leaks by performing a clean-up of the object.
25. What do you mean by reference variable in c++?
Ans: A reference variable provides an alias to a previously defined variable.
Data -type & reference-name = variable name
No comments:
Post a Comment