Procedural vs Object-Oriented Programming

Choose a study mode

Play Quiz
Study Flashcards
Spaced Repetition
Chat to Lesson

Podcast

Play an AI-generated podcast conversation about this lesson
Download our mobile app to listen on the go
Get App

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 (D)</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 (D)</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 (D)</p> Signup and view all the answers

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

<p>C++, JAVA, VB.NET (B)</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 (B)</p> Signup and view all the answers

In C++, what do streams refer to?

<p>Sequences of bytes used for data transfer (A)</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. (D)</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 (C)</p> Signup and view all the answers

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

<p>To read a single character (D)</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. (D)</p> Signup and view all the answers

What is a fundamental disadvantage of procedural programming languages?

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

Which statement best describes object-oriented programming?

<p>It employs messages for object communication to enhance security. (B)</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. (B)</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. (A)</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. (B)</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. (A)</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. (D)</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. (B)</p> Signup and view all the answers

What is a key characteristic of procedural programming languages?

<p>Programs are divided into smaller functions. (C)</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. (A)</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 } (A)</p> Signup and view all the answers

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

<p>COBOL (D)</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. (A)</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. (D)</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. (D)</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); (D)</p> Signup and view all the answers

Flashcards

Procedural Programming

A programming paradigm that structures a program as a sequence of instructions or procedures. It emphasizes the breakdown of a program into smaller, self-contained modules called functions or subroutines.

Object-Oriented Programming (OOP)

A programming paradigm that uses objects to represent entities in a program. It focuses on data and the operations (methods) that can be performed on that data.

Programming Language Syntax

A set of rules that specify the syntax and semantics of a programming language, defining how code should be written.

Function in Programming

A function is a self-contained block of code that performs a specific task. It takes input values (arguments) and may return a result.

Signup and view all the flashcards

Global Data

A feature of procedural programming where data can be accessed and modified by any function in the program.

Signup and view all the flashcards

Top-Down Approach

A program design approach that starts with the overall goal and breaks it down into smaller, more manageable tasks or sub-problems.

Signup and view all the flashcards

Object-Oriented Programming Language

A programming language that uses an object-oriented paradigm, focusing on data and objects.

Signup and view all the flashcards

Procedure-Oriented Programming Language

A programming language that focuses on procedures and functions, often used for scientific and system programming.

Signup and view all the flashcards

Inheritance

In object-oriented programming, when a class inherits properties and methods from its parent class. Descendants inherit the characteristics of their ancestors.

Signup and view all the flashcards

Procedure

In procedural programming, a sequence of instructions that performs a specific task. It's like a recipe for the computer to follow.

Signup and view all the flashcards

Top-Down Design

A programming design method that breaks down a problem into smaller, manageable sub-problems, then systematically solves each one. This promotes organization and efficient problem-solving.

Signup and view all the flashcards

Object-Oriented Programming

A programming paradigm that uses abstraction (classes and objects) to model real-world environments.

Signup and view all the flashcards

Data Security in Object-Oriented Programming

Data can be accessed only through its instances, enhancing data security.

Signup and view all the flashcards

Class

A blueprint or template that defines the structure and behavior of objects. It describes the data (attributes) and actions (methods) an object can have.

Signup and view all the flashcards

Object

A specific instance of a class, possessing unique data and capable of performing actions defined by its class.

Signup and view all the flashcards

Unrestricted Access in Procedural Programming

Allows unrestricted access to global data within functions, potentially leading to data inconsistency.

Signup and view all the flashcards

Real-World Modeling in Procedural Programming

Procedural programming struggles to model complex real-world entities as it separates data and functionality.

Signup and view all the flashcards

C++ I/O Streams

C++ programs use streams to transfer data as sequences of bytes. These streams can act as both the source and destination of data, allowing information to flow in and out of the program.

Signup and view all the flashcards

Text Stream

A text stream represents data as a sequence of characters, organized into lines separated by newline characters. It's like reading a book, with each line ending on a new page.

Signup and view all the flashcards

Binary Stream

A binary stream stores data in its raw binary format. It's like storing data in memory, without any human-readable interpretation.

Signup and view all the flashcards

Cascading of Input/Output Operators

In C++, you can chain input or output operations together. The result of one operation is passed as input to the next one, allowing for efficient data manipulation.

Signup and view all the flashcards

Reading and Writing Characters and Strings

You can read single characters from an input stream using cin.get(). To read a string, use cin>> to read words separated by spaces, or cin.getline() for entire lines, including spaces.

Signup and view all the flashcards

cin

The cin object is used to read input from the standard input stream (typically the keyboard). It's like the program's ear, listening for user input.

Signup and view all the flashcards

cout

The cout object is used to write output to the standard output stream (typically the monitor). It's like the program's mouth, speaking the results.

Signup and view all the flashcards

iostream

C++ programs use the standard library iomanip to format input and output streams. It allows you to control how data appears when displayed or read.

Signup and view all the flashcards

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

More Like This

Object-Oriented vs Procedural Programming
11 questions
Introduction to Programming Concepts
10 questions
Object-Oriented vs Procedural Programming
10 questions
Programming Concepts and Procedures
55 questions
Use Quizgecko on...
Browser
Browser