0% found this document useful (0 votes)
4 views8 pages

C++ 2M

The document outlines the characteristics and concepts of Function-Oriented Programming and Object-Oriented Programming (OOP), including definitions of key terms such as objects, classes, encapsulation, inheritance, and polymorphism. It also discusses the benefits and applications of OOP, along with various programming techniques like operator and function overloading, dynamic memory allocation, and file handling. Additionally, it covers control structures, parameter passing techniques, and the differences between structures and classes.

Uploaded by

thorodinsob19
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views8 pages

C++ 2M

The document outlines the characteristics and concepts of Function-Oriented Programming and Object-Oriented Programming (OOP), including definitions of key terms such as objects, classes, encapsulation, inheritance, and polymorphism. It also discusses the benefits and applications of OOP, along with various programming techniques like operator and function overloading, dynamic memory allocation, and file handling. Additionally, it covers control structures, parameter passing techniques, and the differences between structures and classes.

Uploaded by

thorodinsob19
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 8

1.

list out the characteristics of Funtion oriented Programming Language


a. Large programs are divided into smaller functions
b. Most of the functions share global data
c. Functions transform data from one form to another
d. it employs top-down approach

2. List out the characteristics of OOP


a. programs are divided into objects
b. data is hidden
c. Objects communicate with each other, by sending messages and receiving responses
d. It follows bottom-up approach

3. List down the basic concepts of OOP


a. Objects
b. Classes
c. Data abstraction and encapsulation
d. Inheritance
e. Polymorphism
f. Dynamic binding
g. Message passing

4. Define an Objects
objects are the basic run time entities in an object oriented system. They may represent a
person, a place or any item that a program has to handle.

5. Define Object Oriented Programming


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
members of a hierarchy of classes united through the property called inheritance

6. Define a class.
A class is a way to bind data and its associated function together.
A class is a collection of objects with similar attributes and operations. Once the class has
been defined, we can create any number of objects belonging to that class.
Eg. Class – Account
It will create an object account belonging to the class Account

7. Define Encapsulation
The wrapping up of data and functions in a single unit is known as encapsulation. The data
is kept safe from external interference and misuse. The data is not accessible to the outside world
and only those functions which are wrapped in the class can access it. These functions provide the
interface between the objects data and the program.

8. Define Data hiding


the isolation of data from direct access by the program is called data hiding or information
hiding

9. Define Abstraction
Abstraction refers to the act of representing essential features without including the
background details
10. Define ADT
The classes which are using the concept of data abstraction is known as abstract data types
(ADT)

11. Define data member and member function?


The attributes which are holding the information is known as data members.
The member functions that operate on data member

12. Define Inheritance?


Inheritance is the process by which objects of one class acquire the properties of objects of
another class. The new derived class inherits the members of the base class and also adds its own. It
provides the idea of re-usability. The new class will have the combined features of both the classes.

13. Define Polymorphism?


Polymorphism means the ability to take more than one form.
Polymorphism allows a single name/operator to be associated with different operations
depending on the type of data passed to it. An operation may exhibit different behaviours in
different instances.

14. Define dynamic binding?


Dynamic binding means that the code associated with the given function call is not known
until the time of call at runtime.

15. What is message passing?


It is the process of invoking an operation on an object. In response to a message, the
corresponding function is executed in the object.

16. List down the benefits of OOP.


1. the principle of data hiding helps to build secure programs.
2. through inheritance, redundant code is eliminated
3. software complexity can be easily managed

17. List down the applications of OOP.


1. Real time system.
2. Simulation and modelling.
3. AI and expert system
4. Neural network programming
5. CAD/CAM systems.

18. What is implicit type conversion?


When an expression consists of data items of different types, the compiler performs type
conversions. It is called as implicit type conversion

19. What are the differences between “break” and “continue” statements.
Break: Break statement takes the control to the outside of loop. It is used in loop and switch
statement
Continue: continue statement takes the control to the beginning of loop. It can be used only in loop
statement.

20. Distinguish “while” and “do – while” statements.


While: while is an entry control loop. It is executed when the condition is true.
Do – while: This is an exit control loop. The loop is executed at least once.
21. Give four examples for string manipulation functions
strlen() - finds the length of string
strcpy() - copies the contents of one string to another
strcat() - concatenates two strings into one single string
strupr() - converts a lower case string to upper case
strlwr() - converts a upper case string to lower case

22. List the different types of parameter passing techniques.


i. Pass by value
ii. Pass by address
iii. Pass by reference

24. What is dynamic memory allocation?


Allocation of memory space for any data structure during the of the program execution is
called dynamic memory allocation

25. What are the parts of class specification?


The class specification has two parts:
1. Class declaration – to describe the type and scope of its members.
2. Member function definition - to describe how the member function are implement

26. Write the syntax of class declaration


class class_name
{
private:
Variable declaration;
Functions declaration;
public:
Variable declaration;
Functions declaration;
};

27. Where to define a member function?


Member functions can be defined in two places:
1. Outside the class definition
2. Inside the class definition

28. Give the syntax for member function definition outside class
return-type class_name::function name(arguments)
{
function body;
}

29. List the characteristics of member function


1. Member function can access the private data of a class.
2. A member function can call another member function directly without using the dot operator.

30. List the properties of static members.


A data member of a class can be qualified as static properties.
1. It is always initialized to zero when the first object of the class is created.
2. It is visible only within the class.
31. Write the properties of static member function
1. A static function can have access to only other static members declared in the same class.
2. A static member function can be called using the class name as follows:
class_name::function_name(arguments);

32 Define Constructor?
A constructor is a special member function whose task is to initialize the object of its class.
It is called constructor because it constructs the value of data members of the class.

33. What are the characteristics of constructor?


1. Constructors should be declared in public section.
2. They are involved automatically when the objects are created.
3. They do not have return types.
4. They can not be inherited.

34. Define parameterized constructor.


Arguments can be passed to the constructor function when the objects are created. The
constructors that can take arguments are called as parameterized constructor.

35. What is an implicit constructor?


C++ compiler has an implicit constructor which creates objects even though it was not
defined in the class.

36. What is the use of copy constructor?


Copy constructor is used to declare and initialize an object from another object.
Eg., class_name object2(object1)
It will define the object2 and at the same time it initializes the values of object1 to object2.

37. What is the use of destructor?


Destructor is used to destroy the objects that have been created by a constructor. It releases
the memory space for future use.

38. What are the characteristics of destructor?


1. A destructor is a member function whose name is the same as the class name but it is preceded by
a tilde(~).

39. Define operator overloading?


The process of making an operator to exhibit different behaviour in different instances is
known as operator overloading.

40. Define function overloading?


Performing different types of task using single function name is referred as function
overloading.

41. Define Virtual function.


When the form of a member function is changed at run time, that member function is
referred to as virtual function.

42. What is meant by an object?


 Objects are the basic run-time entities in an object-oriented system.
 Object may represent a person, a place, a table of data or any item that the program must
handle.
 Object may also represent user defined data such as vectors, time and lists.
 When a program is executed, the objects interact by sending message to one another.
 Each object contains data and code to manipulate the data.

43. What are the benefits of OOP?


 Inheritance eliminate redundant code.
 It decreases development time and increases productivity.
 The use of data hiding helps the programmer to build secure programs.
 It is possible to have multiple instances of an object to co-exist without any interference.
 It is easy to partition the work in a project based on objects.
 It can be upgraded from small to large system.
 It makes the interface descriptions with external systems much simpler by using message
passing techniques.
 Software complexity can be easily managed

44. What are the applications of OOP?


 Real time systems.
 Simulation and modelling.
 Object oriented databases.
 Hypertext, hypermedia and experttext
 AI and expert systems.
 Neural networks and parallel programming
 Decision support and office automation systems.
 CAM\CAD systems.

45. Describe I/O operator.


Input Operator:
The operator >> is known as extraction or get from operator. It takes the value from the keyboard
and assigns it to the variable on its right.
Eg: cin>>num;
Output Operator:
The operator << is known as insertion operator. It moves the value from the variable to the output
device.
Eg.: cout<<num

46. Describe tokens


The smallest individual units in a program are known as tokens. C++ has the following
tokens:
 keywords
 identifiers
 constants
 strings
 operators

47. What are the operators available in C++?


 Arithmetic operator
 Relational operator
 Assignment operator
 Logical operator
 Increment/Decrement operator
 Conditional operator
 Bitwise operator
 Special operator
 Scope resolution operator
 Pointer to member operator
 Memory release operator

48. What is meant by operator overloading?


Overloading means assigning different meaning to an operator, depending on the context. It
is used to assign multiple meanings to operators.

49. What are the advantage of new operator?


 It automatically computes the size of the data object.
 It automatically returns the correct pointer type.
 It is possible to initialize the object while creating the memory space.
 Like any other operator, operator new and delete can be overloaded

50. What is the difference between structure and a class?


The members of structure are public by default. The members of class are private by default.

51. What is a friend function?


The functions that are declared with the keyword friend are known as friend functions. A
function can be declared as a friend in any number of classes, it has full access rights to the private
members of the class.
 It can be invoked like a normal function
 It has the objects as arguments
 It is not in the scope of the class to which is has been declared has friend

52. What are the types of inheritance?


 Single Inheritance
 Multiple Inheritance
 Multilevel Inheritance
 Hierarchical Inheritance
 Hybrid Inheritance
Single Inheritance: A derived class with only one base class is called single inheritance
Multiple Inheritance: A class can inherit properties from more than one class which is known as
multiple inheritance
Multilevel Inheritance: A class can be derived from another derived class which is known as
multilevel Inheritance.
Hierarchical Inheritance: When the properties of one class are inherited by more than one class, it is
called hierarchical inheritance.

53. Define virtual base class.


A base class that has been qualified as virtual in the inheritance definition. In multiple inheritance, a
derived class can inherit the members of a base class via two or more inheritance paths. If the base
class is not virtual, the derived class will inherit more than one copy of the members of the base
class.

54. Define virtual function.


It is a function qualified by the virtual keyword. When a virtual function is called via a pointer, the
class of the object pointed to determines which function definition will be used. Virtual functions
implement polymorphism, whereby objects belonging to different classes can respond to the same
message in different ways.
55. What is meant by this pointer?
C++ uses the unique keyword called this to represent an object that invokes a member function.
this is a pointer that points to the object for which this function was called. This unique pointer is
automatically passed to a member function when it is called. The pointer this acts as an implicit
argument to all the member functions.

56. What are C++ streams?


The C++ language offers a mechanism, which permits the creation of an extensible and consistent
input-output system in the form of streams library. It is a collection of classes and objects which can
be used to build a powerful system or it can be modified and extended to handle user defined data
types.

57. List the predefined console streams.


a) cin – standard input
b) cout – standard output
c) cerr – standard error output
d) clog – fully buffered version of cerr

58. Give the usage of ios class.


The ios class provides operations common to both input and output. It contains a pointer to a buffer
object. It has constants and member functions that are useful in handling formatted I/O operations.
Following are the derived classes of ios class:
a) istream – input stream
b) ostream – output stream
c) iostream – input-output stream

59. What are the types of manipulators? Give example.


Two types of manipulators are available
a) Parameterized manipulators
b) Non-parameterized manipulators

a) Parameterized manipulators
setw(int width) – sets the field width
setprecision(int prec) – sets the floating point precision

b) Non-parmeterized manipulator:
dec – sets the conversion base to 10
endl – outputs a new line and flushes stream

60. Define ifstream & fstream


ifstream: It is used for handling input files. It contains open() with default input mode and inherits
get(), getline(), read(), seekg(), tellg() functions from istream.

Fstream: used for handling files on which I/O operations can be performed. It supports
simultaneous I/O operations. It can open() with default input mode and inherits all the functions
from istream and ostream classes through iostream.
61. List any four file modes and their purpose
a) ios::in – open for reading
b) ios::ate – seek to the end of file at opening time
c) ios::nocreate – open fails if file does not exist.
d) ios::binary – opens a binary file

62. List the file pointer control functions.


a) seekg() - moves get file pointer to a specific location
b) seekp() - moves put file pointer to a specific location
c) tellg() - returns the current position of the get pointer
d) tellp() - returns the current position of the put pointer

63. What are the types of file accessing?


a) Sequential access
sequential access type of file is to be accessed sequentially that is to access a particular data
all the preceding data items have to be read and discarded.
b) Random access:
Random access type of file allows access to the specific data directly with out accessing its
preceding data items.

You might also like