Procedural vs Object-Oriented Programming
29 Questions
0 Views

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to lesson

Podcast

Play an AI-generated podcast conversation about this lesson

Questions and Answers

What is the main design method used in procedural programming?

  • Incremental Design
  • Top Down Design (correct)
  • Modular Design
  • Bottom Up Design
  • What is a significant difficulty associated with procedural programming?

  • Changes in the main procedure can affect downstream procedures (correct)
  • Procedural languages require more memory
  • Modules cannot be tested separately
  • Procedural programming cannot be used in large projects
  • What aspect of object-oriented programming addresses issues found in procedural programming?

  • Automatic availability of class instances (correct)
  • Enhanced user interfaces
  • Improved testing methods
  • Separation of code and data
  • How do modules function in procedural programming?

    <p>As parts that can be coded and tested separately</p> Signup and view all the answers

    What can happen to sub procedures when changes are made to the main procedure in a procedural programming context?

    <p>They may require individual modifications</p> Signup and view all the answers

    What character signifies the end of a line in a text stream in C++?

    <p>New-line character</p> Signup and view all the answers

    Which programming languages are primarily known for being object-oriented?

    <p>C++, JAVA, VB.NET</p> Signup and view all the answers

    What is the primary way in which object-oriented programming enhances security compared to procedural-oriented programming?

    <p>By providing access specifiers</p> Signup and view all the answers

    In C++, what do streams refer to?

    <p>Sequences of bytes used for data transfer</p> Signup and view all the answers

    Which of the following statements is correct regarding global and local data in programming?

    <p>Local data is more secure compared to global data.</p> Signup and view all the answers

    Which type of stream contains raw binary data values interpreted according to their memory representation?

    <p>Binary stream</p> Signup and view all the answers

    What is the purpose of the 'cin.get()' function in C++?

    <p>To read a single character</p> Signup and view all the answers

    What differentiates functions in procedural-oriented programming from objects in object-oriented programming?

    <p>Functions perform tasks while objects encapsulate data.</p> Signup and view all the answers

    What is a fundamental disadvantage of procedural programming languages?

    <p>Functions can access global data without restriction.</p> Signup and view all the answers

    Which statement best describes object-oriented programming?

    <p>It employs messages for object communication to enhance security.</p> Signup and view all the answers

    How does object-oriented programming improve code maintainability?

    <p>By allowing the creation of modular programs using classes.</p> Signup and view all the answers

    What does the term 'class' indicate in object-oriented programming?

    <p>A template that defines the properties and behaviors of objects.</p> Signup and view all the answers

    Which of the following is NOT a key characteristic of object-oriented programming?

    <p>Static and unchanging object properties.</p> Signup and view all the answers

    Which aspect of object-oriented programming contributes to its flexibility?

    <p>The modular nature of classes and objects.</p> Signup and view all the answers

    In object-oriented programming, what is primarily meant by 'inheritance'?

    <p>A relationship where a class derives attributes and behaviors from another.</p> Signup and view all the answers

    What is the relationship between an object and a class in object-oriented programming?

    <p>Every object is an instance of a class.</p> Signup and view all the answers

    What is a key characteristic of procedural programming languages?

    <p>Programs are divided into smaller functions.</p> Signup and view all the answers

    Which of the following is NOT a feature of procedure-oriented programming?

    <p>Encourages the use of encapsulation.</p> Signup and view all the answers

    In a procedure-oriented programming language, how is a function typically defined?

    <p>Return-type function-name(arguments) { body of function }</p> Signup and view all the answers

    Which of the following programming languages is an example of a procedure-oriented programming language?

    <p>COBOL</p> Signup and view all the answers

    What is the main purpose of the main program in procedural programming?

    <p>To coordinate calls to procedures and manage data.</p> Signup and view all the answers

    What does the term 'top-down approach' refer to in the context of procedure-oriented programming?

    <p>Breaking down a large task into smaller tasks until they are manageable.</p> Signup and view all the answers

    Which of the following best describes the nature of data in procedural programming languages?

    <p>Data is global and shared among functions.</p> Signup and view all the answers

    Which of the following function call examples follows the proper syntax for procedural programming?

    <p>add(5,10);</p> Signup and view all the answers

    Study Notes

    Course Information

    • Course Title: Object Oriented Design and Programming
    • Course Code: 18CSC202J
    • Unit: 1
    • Prepared by: CINTEL Team
    • Date: 8/24/2022

    Procedural vs Object Oriented Programming

    • Procedural Programming: A program is a list of instructions. Larger programs are divided into smaller programs called functions. Each function has a clearly defined purpose and a clearly defined interface to the other functions in the program.
    • Procedural language data is usually global and shared by all the functions. Procedural language designs are commonly Top-Down. Languages like C, COBOL, and FORTRAN use this approach.
    • Object-Oriented Programming: Objects of the program interact by sending messages to each other, and data security is enhanced because data can only be accessed through its instances. Object-oriented programming is meant to address difficulties in procedural programming with regards to software maintaining which leads to time-consuming processes.

    C Function Aspects

    • Function Declaration: Return-type function-name(argument list); Eg: int add(int a, int b);
    • Function Definition: Return-type function-name(argument list){body of function;} Eg: int add(int a, int b){int c; c=a+b; return c;}
    • Function Call: Function-name(argument list); Eg: add(5,10);

    Features of Procedure Oriented Programming

    • Smaller programs are used
    • Larger programs are divided into smaller programs known as functions.
    • Each function has a clearly defined purpose
    • Each function has a clearly defined interface to the other functions
    • Data is global and shared by almost all the functions
    • Top-Down approach used in program design

    Examples of Procedure Oriented Programming Languages

    • COBOL
    • FORTRAN
    • C

    Sample COBOL Program

    • Shows program structure with IDENTIFICATION, ENVIRONMENT, and DATA divisions. The WORKING-STORAGE section defines variables (e.g., A, B, ANS) to store numerical values.
    • The PROCEDURE DIVISION describes the steps in the program: main processing, adding the variables, displaying results, and terminating.

    Disadvantages of Procedural Programming

    • Unrestricted access: Functions have unrestricted access to global data.
    • Real-world modeling: Unrelated functions and data do not effectively model real-world objects, which typically have attributes (data) and behavior (functions).

    Object-Oriented Concepts

    • Objects in a program interact by sending messages to each other. This improves data security, as data can only be accessed through its instances.
    • Every object has its own memory.
    • Computation is performed through objects communicating with each other.
    • Every object is an instance of a class. A class simply groups similar objects.
    • A class is the repository for behavior associated with an object, meaning all objects from the same class perform the same actions.
    • Classes are organized in a tree structure known as the inheritance hierarchy.
    • Memory and behavior associated with instances of a class are automatically available to any class associated with a descendant in this tree structure.

    Studying That Suits You

    Use AI to generate personalized quizzes and flashcards to suit your learning preferences.

    Quiz Team

    Related Documents

    Unit 1 Introduction to OOPS PDF

    Description

    This quiz explores key concepts in procedural and object-oriented programming, including design methods, challenges, and the roles of modules and data streams in C++. Test your understanding of the differences between these programming paradigms and their implications for security and data handling.

    More Like This

    Use Quizgecko on...
    Browser
    Browser