Object Oriented Programming: Chapter 1: Principles of Object Oriented Programming

Principles of Object Oriented Programming: Two Marks Important Questions and Answers

Object Oriented Programming

Object Oriented Programming: Chapter 1: Principles of Object Oriented Programming: Anna University Part A Two Marks Important Questions and Answers

Object Oriented Programming

Chapter 1: Principles of Object Oriented Programming

 

Two Marks Questions with Answers

 

1. Differentiate (any two features) object oriented programming from procedure oriented programming.

Answer: :


Procedural programming language

1.The procedure oriented programming language executes series of procedures sequentially.

2. Data reusability is not possible.

Object oriented programming language

1. In object oriented programming approach there is a collection of objects.

2.Data reusability is possible in this approach.

 

2. With respect to C++ distinguish 'object' from 'classes'.

Answer: : A class is a definition which contains the code for an object. And object is an instance of a class. For example ‒ River is the class and Ganga, Yamuna, Kaveri are the objects.

 

3. Differentiate between object and class.

Answer: :


Class

1. For a single class there can be any number of objects. For example ‒ If define the class as river then ganga, la, narmada can be the objects of the class river.

2.The scope of the class is persistent throughout the program.

3. The class can not be initialized with some property values.

4. A class has unique name.

Object

1.There are many objects that can be created from one class. These objects make use of the

methods and attributes defined by the belonging class.

2.The objects can be created and destroyed as per the requirements.

3.We can assign some property values to the objects.

4.Various objects having different names can be created for the same class.

 

4. List some applications of OOP.

Answer:

Following are some areas in which the object oriented programming is used ‒

1. For creating object oriented databases

2. For implementing the real time systems

3.For implementing the knowledge based systems.

4. For neural networks and parallel programming

5. In game programming

6. For office automation and business logic implementation

7. For CAD/CAM systems.

8. For simulation and modeling.

 

5. Give at least two merits of object oriented programming.

Answer:

 1. Using object oriented programming it is possible to hide the data from unauthorized access.

2. There is a concept of inheritance using which some classes can use the properties and functions of the common class.

 

6. Give at least two drawbacks of object oriented programming.

Answer:

1. The object oriented programming is complex to implement, because every entity in it is an object.

2. If some of the members are declared as private then those members are not accessible by the object of another class. In such a case you have to make use of inheritance property.

 

7. Enlist the object oriented programming principles.

Answer: Various principles of object oriented programming are ‒

1. Encapsulation

2. Inheritance

3. Polymorphism

4. Dynamic binding.

 

8. What is object oriented programming ?

Answer: Object oriented programming is a programming approach in which there is collection of objects.

 

9. Define data abstraction

           OR

What is meant by data abstraction.

 Answer: Data abstraction means representing only essential features by hiding all the implementation details.

 

10. What is OOP ?

Answer: The OOP stands for object oriented programming. The object oriented programming is an approach which makes use of objects for developing the systems.

 

11. What is method ?

Answer: Method is an object's behavior. It is represented by the functionality of a class. These functions are used to operate on data.

 

12. State how data encapsulation support reusability.

 Answer: Data encapsulation is a technique in object oriented programming by which the data is tied with the methods that operate on data. This encapsulation forms an entity called class. In object oriented programming, a new class can be derived from some base class by inheriting the required features of it. Thus due to encapsulation, the base class can be inherited and the data or methods of base class can be reused by the derived class.

 

13. What are the advantages of object oriented programming over structured programming language?

Answer:

1. Object oriented programming makes use of modular programming approach. Due to this changes can be made in the modules without affecting rest of the code. Using object of a class the function of that class can be accessed. On the other hand in the structured programming approach the focus is on procedures or functions. There are chances of manipulation of the functions during the code modification.

2. Object oriented programming allows data reusability by means of inheritance. However, the concept of inheritance is not allowed in structured programming languages.

 

14. Give at least two differentiating factors between C and C++,

Answer: 1. C is a procedure oriented language while C++ is a object oriented programming language,

2. C does not support inheritance, polymorphism, class and object concepts while C++ support inheritance, polymorphism, class and object concepts.

 

15. Explain the term polymorphism.

Answer: Polymorphism is an ability to take more than one form and refers to the operation exhibiting different behavior in different instances or situations.

 

16. What is the use of dynamic binding?

Answer:  Dynamic binding is a technique which determines which function is to be called for particular object. It is basically the association of code with given procedure call. This association is done at runtime.

 

17. List the operators used in C++ for handling memory.

Answer: The new and delete are the two operators that are used in handling memory in C++. The new operator is used to allocate the memory and delete operator is used to deallocate the memory.

 

18. What is a keyword in C++?

Answer: In C++, keyword is a special word which has some meaning associated with it. For example ‒ if, for, while, do, cout, cin are some keywords used in C++. The keywords cannot be used as the names of the identifiers.

 

19 .Explain the use of enum in C++.

  Answer: The enum is a user defined data type, Using this the set of predefined constants can be created and those values can be assigned to the variables.

 

20 .What is conditional operator ?

Answer: The conditional operator is ?. The syntax of this operator is

icondition?expression1:expression2.

For example

a>b?true:false

That means if a is greater than b then the value will be true otherwise it will be false.

 

21. What are escape sequences ?

Answer: There are some non printing special characters which are called escape sequences. For example ‒ \n, \b,\\

 

22. Explain how comments can be specified in C++.

Answer: In C++ there are two ways by which the comments can be specified. The single line comment can be specified using the operator //. For example :

//This is a commented line

Another way is to use /* and */. These two notations are used to denote the beginning and end of the comment statements respectively. For example ‒

/*This is first line

Second line

and so on

All are commented

*/

 

23. Define ‒ Type conversion.

Answer: The type conversion is a process in which variable in one data type can be converted to another data type.

 

24. Specify the syntax for C++ style type conversion.

Answer: Datatype (expression)

For example

ans = double (a);

 

25. What are input and output operators in C++ ?

Answer: The <<< (insertion operator) is for output operation and >> (extractor operator) is for input operation in C++.

 

26. What is ternary operator ?

Answer: The ternary operator is also called as conditional operator. This operator is called ternary operator because it takes three arguments. The syntax of ternary operator is

condition?expression1:expression2

For example

a<b?true:false

That means if a is less than b then it will return true otherwise false.

 

Object Oriented Programming: Chapter 1: Principles of Object Oriented Programming : Tag: Oops, Computer Programming : Object Oriented Programming - Principles of Object Oriented Programming: Two Marks Important Questions and Answers


Object Oriented Programming: Chapter 1: Principles of Object Oriented Programming



Under Subject


Object Oriented Programming (OOPs)

CS25C07 2nd Semester CSE, CSE(CY) Depts | 2025 Regulation | 2nd Semester 2025 Regulation



Related Subjects


English Essentials II

EN25C02 2nd Semester | 2025 Regulation | 2nd Semester 2025 Regulation



Linear Algebra

MA25C02 2nd Semester | 2025 Regulation


Applied Physics (CSIE) II

PH25C03 2nd Semester AIDS, CSE, IT, CSE(CY) Dept | 2025 Regulation | 2nd Semester 2025 Regulation


Digital Principles and Computer Organization

CS25C06 2nd Semester AIDS, CSE, IT, CSE(CY) Dept | 2025 Regulation | 2nd Semester 2025 Regulation


Basic Electrical and Electronics Engineering

EE25C01 2nd Semester | 2025 Regulation | 2nd Semester 2025 Regulation


Object Oriented Programming (OOPs)

CS25C07 2nd Semester CSE, CSE(CY) Depts | 2025 Regulation | 2nd Semester 2025 Regulation


Re-Engineering for Innovation

ME25C05 2nd Semester | 2025 Regulation | 2nd Semester 2025 Regulation


Object Oriented Programming (OOPs) - Laboratory

CS25C07 2nd Semester CSE, CSE(CY) Depts | 2025 Regulation | 2nd Semester 2025 Regulation