Sie sind auf Seite 1von 2

Q.1: Why Inheritance?

Inheritance is a mechanism for

• building class types from existing class types

• defining new class types to be a –specialization –augmentation of existing types

Q.2: Object-oriented programming is a programming methodology characterized?

Data Abstraction: problem solving via the formulation of abstract data types (ADT's).

2. Encapsulation: the proximity of data definitions and operation definitions.

3. Information hiding: the ability to selectively hide implementation details of a given ADT.

4. Polymorphism: the ability to manipulate different kinds of objects, with only one operation.

5. Inheritance: the ability of objects of one data type, to inherit operations and data from another data
type. Embodies the "is a" notion: a horse is a mammal, a mammal is a vertebrate, a vertebrate is a life
form.

Q.3: Characteristics of OOP?

Encapsulation: Combining data structure with actions Data structure: represents the properties, the
state, or characteristics of objects Actions: permissible behaviors that are controlled through the
member functions.

Inheritance: Ability to derive new objects from old ones permits objects of a more specific class to
inherit the properties (data) and behaviors (functions) of a more general/base class ability to define a
hierarchical relationship between objects.

Polymorphism: Ability for different objects to interpret functions differently.

Q.4: What is a pointer variable?

• A pointer variable is a variable whose value is the address of a location in memory.

e.g,

int* ptr; // ptr will hold the address of an int

char* q; // q will hold the address of a char

Q.5: Why Reference Variables?

• Are primarily used as function parameters


• Advantages of using references: – you don’t have to pass the address of a variable – you don’t have to
dereference the variable inside the called function.

Q.6: How much types of Memory?

Static memory - where global and static variables live

Heap memory - dynamically allocated at execution time - "managed" memory accessed using pointers

Stack memory - used by automatic variables

Q.7: Three Kinds of Program Data

• STATIC DATA: Allocated at compiler time

• DYNAMIC DATA: explicitly allocated and deallocated during program execution by C++ instructions
written by programmer using operators new and delete.

• AUTOMATIC DATA: automatically created at function entry, resides in activation frame of the
function, and is destroyed when returning from function.

Q.8: Access Specifiers?

Public • may be accessible from anywhere within a program –

Private • may be accessed only by the member functions, and friends of this class –

Protected:

• Acts as public for derived classes

• behaves as private for the rest of the program

Q.9: What is an object?

OBJECT is a set of methods (member functions)

OR

Internal state (values of private data members)

Das könnte Ihnen auch gefallen