Procedural and Object Oriented Programming

Cards (49)

  • The super() function gives a child class access to a parent classes methods and attributes
  • The super() function returns an object that represents the parent class
  • Abstract data structure
    A mathematical model for data structure.
  • Abstraction
    Anything unnecessary to the current task is ignored
  • Array
    A form of data structure used to store a set of data elements of the same data type in a certain order.
  • Attributes
    Information stored about objects that are derived from a class.
  • Behaviour
    Procedures associated with class.
  • Class
    A blueprint of an object.
  • Constructor
    Subroutines used to create a new object.
  • Data structure
    A collection of data structured together in a specific format.
  • Encapsulation
    A programming concept in which direct access is restricted to some components of an object.
  • Inheritance
    A programming concept in which classes acquire attributes and methods from another class.
  • Method
    Procedures associated with class.
  • Object
    Any physical or logical entity that has a state and behaviour. It is an instance of a class.
  • An abstract class is used to make subclasses
  • An abstract class is not used for what?

    making objects
  • OOP stands for?
    Object oriented programming
  • A collection of methods with no implementation is called what in java?

    Interface
  • Interfaces in java are used to declare a behaviour that a class must implement.
  • What type of attribute or method cannot be accessed from outside a class?

    Private
  • What type of attributes and emthods can be acessed anywhere in a program?
    Global
  • What type of attributes and methods can be acessed from outside the class?

    public
  • Adding new code to a procedurally programmed program is difficult
  • Adding new code to an object orientated program is easy
  • In procedural programming it is easy to write a program that can be used in numerous ways
  • Both procedural programming and OOP use abstraction
  • 2 examples of procedural programming languages are C and Pascal
  • 2 examples of OOP languages are:
    Java
    C#
  • In OOP it is easy to encapsulate data so it cannot be accessed from outside the class
  • Inheritance is using another classes methods and attributes in a new sub/child class
  • Polymorphism is having a method that can be used for multiple things
  • Class diagrams use arrows to show inheritance
  • Encapsulation is when an object controls it's own state and is therefore seperate from the program especially in OO programming languages, in which attributes and methods can be made private, making it only possible to reference them within a class
  • Dunder stands for double underscore and is used when constructing a class (__init__) but can also do what?

    Override certain inbuilt methods and attributes such as __add__ or __name__
  • An example of dunder with addition is
    class Animal:
      def __init__(self, name):
        self.name = name
      def __add__(self, another_animal):
        return Animal(self.name + another_animal.name)
    print('horse' + 'penguin')
    Would print?
    horsepenguin
  • ABC is abstract base class and is used to create abstract classes which define a framework for other classes
  • An abstract class can use abstract methods to what?
    Require a sub class defines that method or an attribute error will be returned
  • An abstract method cannot be?
    Passed
  • public object data can be accessed from anywhere
  • Protected classes can be indicated in python with a single underscore before the method or attributes name