Programming paradigms Flashcards

(28 cards)

1
Q

What is programming paradigms?

A

Different approaches to using a programming language to solve a problem.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the Two Broad categories of programming paradigms?

A

imperative and declarative

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What does the imperative Paradigm contain?

A

Procedural and Object orientated paradigms

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does the Declarative Paradigm contain?

A

logic and functional paradigms

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What type of code does imperative programming paradigms use?

A

use code that clearly specifies the actions to be performed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What type of code does procedural programming paradigms use?

A

Uses a sequence of instructions which may be contained within procedures. These instructions are carried out in a step-by-step manner.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What are benefits of procedural programming paradigms?(2)

A

Can be applied to a wide range of problems
And is relatively easy to write and interpret

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is OOP paradigms?

A

OOP is built on entities called objects, formed from classes which have
certain attributes and methods. OOP focuses on making programs that are reusable and easy to update and maintain.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

When is OOP mainly used?

A

Certain types of problem with lots of reusable components which have similar
characteristics.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is declarative programming?

A

The language states what is required but not how to do it and The statements do not have to be in a specific order

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Where is declarative language commonly used?

A

This type of programming is common in expert systems and artificial intelligence

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is functional programming?

A

It’s a programming style that builds programs by combining reusable functions, similar to how math works. Functions are the main building blocks.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is Logic programming?

A

A style of programming where you define facts and rules, and use queries to find answers. The computer figures out how to solve the problem for you.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is recursion in programming?

A

Recursion is when a function calls itself . It keeps calling itself until it reaches a base case, which stops the recursion.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What type of language is assembly code?

A

Assembly code is a low-level language that is closely related to machine code

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

Why is assembly language easier to use then machine code?

A

Assembly language uses mnemonics rather than binary,

17
Q

What is a class?(3 marks)

A

A template defining methods and attributes used to make objects

18
Q

What is inheritance?(3 marks)

A

Inheritance is when a class takes on the methods and attributes of a parent class .

19
Q

What is special about and inherited class?(2 marks)

A

The inheriting class may override some of these methods/attributes and
may have additional extra methods and attributes of its own .

20
Q

What is the main class sometime called?

A

The base class.

21
Q

Describe three features of an object-oriented language.

A

1.They have classes which contains methods and attributes.
2.Uses encapsulation to hide data within objects,
3.Has inheritance where there are sub classes and superclass’s.

22
Q

What happens when an attribute is private?

A

It cant be directly accessed and therefore public methods are used to change/read
the attributes value.

23
Q

How would we initialise this class?
class video
private name
private views
private starrating

       public procedure new(newname)
            name = NewName
            views = 0
            starrating = 3
       end procedure   end class
A

video1= new video(“Macbeth”)

24
Q

How would we use inheritance (Show the line of code)

A

Class (newclass) inherits(main class)

25
How would we write The constructor?
Public procedure new(givename) givename=name
26
What does super.methodname(parameter) do?
Call the method of the main class.
27
How would we use methods on an object,
1.We instantiate an object, 2.Then we do variable name.method(paramter)
28
Compare two differences between recursion and iteration.
1.Recursion uses more memory while iteration uses less memory. 2.Recursive can run out of memory while iteration cannot run out of memory 3.Recurrsion calls itself while iteration doesn't.