Programming Paradigms - Questions and Answers

Short Answer Questions

1. What do you mean by programming paradigm?
A programming paradigm is a fundamental style or approach to writing software, such as procedural, object-oriented, or functional programming, which dictates how code is structured and executed.
2. Define object.
An object is an instance of a class that contains data (attributes) and behaviors (methods) in object-oriented programming.
3. Define class.
A class is a blueprint or template for creating objects, defining properties and methods that the objects created from the class will have.
4. What is encapsulation?
Encapsulation is the bundling of data and the methods that operate on that data within a single unit or class, restricting direct access to some of an object's components.
5. What is data hiding?
Data hiding is a concept of encapsulation that restricts access to the internal data of an object, protecting it from unintended interference by making it private.
6. What is polymorphism?
Polymorphism allows methods to be used in different ways, enabling a single interface to represent different underlying forms (e.g., method overloading or overriding).
7. Name four object-oriented programming languages.
  • Java
  • C++
  • Python
  • C#
8. Name two procedure-oriented programming languages.
  • C
  • Fortran
9. Name the first object-oriented language.
The first object-oriented language is Simula, developed in the 1960s.
10. What is abstraction?
Abstraction is the process of hiding complex implementation details and showing only the essential features of an object to the user.

Long Answer Questions

1. Mention four characteristics of procedure-oriented programming.
  • Focuses on procedures or functions to operate on data.
  • Data is often global and can be accessed by any function.
  • Emphasizes a top-down approach to problem-solving.
  • Lacks direct support for data encapsulation and inheritance.
2. Mention two advantages and two disadvantages of procedure-oriented programming.
  • Advantages: Simple and easy to understand; Efficient for small programs.
  • Disadvantages: Difficult to maintain for large programs; Lack of data security due to global data access.
3. Explain four features of OOP.
  • Encapsulation: Bundling data and methods together, restricting access to some components.
  • Inheritance: Allows a class to inherit properties and methods from another class.
  • Polymorphism: Enables methods to be used in multiple forms.
  • Abstraction: Hides complex details and shows only necessary features.
4. List four advantages of OOP.
  • Reusability of code through inheritance.
  • Improved data security via encapsulation.
  • Easier maintenance and modification of code.
  • Facilitates better organization and structure of large programs.
5. Differentiate between procedure-oriented programming and object-oriented programming.
  • Approach: Procedure-oriented focuses on functions, while object-oriented focuses on objects.
  • Data Access: Procedure-oriented uses global data, while object-oriented encapsulates data.
  • Scalability: Object-oriented is better for large, complex systems; procedure-oriented suits smaller programs.
  • Features: Object-oriented includes inheritance and polymorphism; procedure-oriented does not.