Ans: It is an entity which may correspond to real world things .Every object will have data structures called attributes and behavior called operations.
2.what is the class?
Ans:class is the logical representation
which hold the data and functions.
3. What is the difference between an object and a class?
Ans:A class is logical representation
while a object is an real exsitence
All objects possessing similar properties are grouped into class.
Example :–person is a class, ram, hari are objects of person class. All have similar attributes like name, age, and similar operations like speak, walk. Class person { private: char name[20]; int age; char sex; public: speak(); walk(); };
4. What is the difference between class and structure?
Ans: In class the data members by default are private but in
structure they are by default public
5. Define object based programming language?
Ans: Object based programming language support encapsulation and object identity without supporting some important features of OOPs language.
6. Define object oriented language?
\Ans: Object-oriented language incorporates all the features of object based programming languages along with inheritance and polymorphism.
Example: – c++, java.
7. Define OOPs?
Ans: OOP is a method of implementation in which programs are organized as co-operative collection of objects, each of which represents an instance of some class and whose classes are all member of a hierarchy of classes united through the property of inheritance.
8. What is public, protected, and private?
Ans: These are access specifier .The class member that has been declared as private can be accessed only from within the class. Public members can be accessed from outside the class also. Within the class or from the object of a class protected access limit is same as that of private but it plays a prominent role in case of inheritance
9. 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.
10. What do you mean by 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.
11. What is abstraction?
Ans: The technique of creating user-defined data types, having the properties of built-in data types and a set of permitted operators that are well suited to the application to be programmed is known as data abstraction. Class is a construct for abstract data types (ADT).
12. What is encapsulation?
Ans: It is the mechanism that wraps the data and function it manipulates into single unit and keeps it safe from external interference.
13. 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.
14. What are the c++ tokens?
Ans: c++ has the following tokens I. keywords II. Identifiers III. Constants IV. Strings V. operators
15. 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
16. What do you mean by implicit conversion?
Ans: Whenever data types are mixed in an expression then c++ performs the conversion automatically. Here smaller type is converted to wider type. Example- in case of integer and float integer is converted into float type.
17. What is the difference between method overloading and method overriding?
Ans: Overloading a method (or function) in C++ is the ability for functions of the same name to be defined as long as these methods have different signatures (different set of parameters). Method overriding is the ability of the inherited class rewriting the virtual method of the base class.
18. What are the defining traits of an object-oriented language? The defining traits of an object-oriented language are: encapsulation inheritance polymorphism
Ans: Polymorphism: is a feature of OOPL that at run time depending upon the type of object the appropriate method is called. Inheritance: is a feature of OOPL that represents the “is a” relationship between different objects (classes). Say in real life a manager is a employee. So in OOPL manger class is inherited from the employee class. Encapsulation: is a feature of OOPL that is used to hide the information.
19. What is polymorphism?
Ans: Polymorphism is the idea that a base class can be inherited by several classes. A base class pointer can point to its child class and a base class array can store different child class objects.
20. What do you mean by inline function?
Ans: An inline function is a function that is expanded inline when invoked.ie. the compiler replaces the function call with the corresponding function code. An inline function is a function that is expanded in line when it is invoked. That is the compiler replaces the function call with the corresponding function code (similar to macro).
21 What is the difference between a NULL pointer and a void pointer?
Ans: A NULL pointer is a pointer of any type whose value is zero. A void pointer is a pointer to an object of an unknown type, and is guaranteed to have enough bits to hold a pointer to any object. A void pointer is not guaranteed to have enough bits to point to a function (though in general practice it does).
22. What is difference between C++ and Java?
Ans: C++ has pointers Java does not. Java is platform independent C++ is not. Java has garbage collection C++ does not.
23. What do you mean by multiple inheritance in C++ ?
Ans: Multiple inheritance is a feature in C++ by which one class can be of different types. Say class teaching Assistant is inherited from two classes say teacher and Student.
24. What do you mean by virtual methods?
Ans: virtual methods are used to use the polymorphism feature in C++. Say class A is inherited from class B. If we declare say function f() as virtual in class B and override the same function in class A then at runtime appropriate method of the class will be called depending upon the type of the object
25What is a constructor?
Ans: Constructor is a special member function of a class, which is invoked automatically whenever an instance of the class is created. It has the same name as its class.
26. What is destructor?
Ans: Destructor is a special member function of a class, which is invoked automatically whenever an object goes out of the scope. It has the same name as its class with a tilde character prefixed. (~)
27. What is virtual function?
Ans: A virtual function is a member function that is declared within a base class and redefined by a derived class .To create a virtual function, the function declaration in the base class is preceded by the keyword virtual.
28. What do you mean by early binding?
Ans:Early binding refers to the events that occur at compile time. Early binding occurs when all information needed to call a function is known at compile time. Examples of early binding include normal function calls, overloaded function calls, and overloaded operators. The advantage of early binding is efficiency.
29. What do you mean by late binding?
Ans: Late binding refers to function calls that are not resolved until run time. Virtual functions are used to achieve late binding. When access is via a base pointer or reference, the virtual function actually called is determined by the type of object pointed to by the pointer.
0 comments:
Post a Comment