1.2.4 Types of Programming Languages Flashcards
1
Q
What do Procedural programs consist of
A
- Consist of statements that tell the computer exactly what to do and are executed line by line
- The basic module of a procedural program is the procedure which is a section of code that performs a task.
- Functions are also modules but they return a value
2
Q
What is a paradigm
A
- To describe an example of a way of doing things
- Styles of programming
3
Q
Why do programmers use procedural languages
A
- Because such languages enable them to focus on the logic problem rather than worrying about high level concepts such as software reuse.
4
Q
What are the key features of procedural languages
A
- Code is run serially, one line after another
- The language supports selection, iteration and assignment and sequence
- Code is developed in a modular way - blocks of code identifying set tasks
- Uses identifiers for variables, constants, prrocedures and functions
- Variables have either local or global scope
5
Q
What is Object-Oriented Programming
A
- Selection, iteration, identifiers for variables and constants are available in OO
- Procedures are replaced by classes, objects and methods
- Offers a more modular design, classes allow the developer to produce more reusable code .
- Captures a group of information data and related functionality into Objects
6
Q
What are the 3 characteristics that define an object-oriented language
A
- Encapsulation
- Inheritance
- Polymorphism
7
Q
In OO what are objects and classes
A
- Object - when you create an instance of a class. Each object that is instantiated from the same class will share the same attributes and methods.
- Class -A template (1) defining methods and attributes (1) used to make objects (1).
8
Q
What are the 3 main sections of a class
A
- Name of the class (light bulb)
- Attributes - information shared by any object in the class type (variable) (wattage, colour)
- Methods - code associated with the class, allows access or change to attributes (subroutines) (get Wattage () , get colour()
9
Q
What is Inheritance
A
- When a class takes on the methods and attributes of a parent class.
- The inheriting class may override some of these methods/attributes and may have additional extra methods and attributes of its own
10
Q
What is Polymorphism
A
- Something that occurs in several different forms.
- There are two main types of polymorphism in object-oriented programming - static and dynamic.
- Polymorphism means that objects of different types can be treated in the same way
11
Q
What is Static Polymorphism
A
- Allows you to implement multiple methods of the same name but with different parameters (within the same class)
- This process is known as method overloading
- The parameter must differ:
- different number of parameters
- The types of parameters need to be different (e.g 1 string, 1 integer)
- Accept the parameters in a different order
12
Q
What is Dynamic Polymorphism
A
- Within an inheritance hierachy, a subclass is able to override a method of its superclass - this allows the code of the subclass to customise or completely replace the behaviour of that method
- This form of polymorphism - both methods share the same name and parameters, but provide different functionality depending on whether they are implemented by the superclass or subclass
13
Q
How do you create a class
A
- Classes in python are defined using the class keyword (class) and indentation.
- Methods are created using the def keyword.
- The biggest difference is that all methods must have at least 1 parameter called self and be inside the class indentation block.
- Self enables functions in Python access to attributes and methods of the class
14
Q
How do you use attributes and inheritance in python
A
- Attributes must be defined in order for them to be part of the class
* Occurs in the _init_(self) method - called when the class is instatiated. Known in OO terms as a constructor - The base class must be defined first. Put the name of the class in brackets after the name of the subclass. class Scientific (Calculator)
15
Q
What is assembly language
A
- An assembly language is a low-level programming language for a computer in which there is 1-1 correspondence with the language and machine code instructions
- Each assembly language is specific to a particular computer architecture