1. What is a class?
Ans: The objects with the same data structure
(attributes) and behavior (operations) are called class.
2. What is an object?
Ans: It is an entity which may correspond to real-world
entities such as students, employees, bank account. It may be concrete such as
file system or conceptual such as scheduling policies in multiprocessor
operating system.
Every object will have data structures called attributes and
behavior called operations.
3. What is the difference between an object and a class?
Ans: 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, sex 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.
Object based language=Encapsulation + object Identity
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 or a visibility lebels
.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
No comments:
Post a Comment