2.4 Types Of Programming Language Flashcards

1
Q

What are 2 types of programming paradigms and what is the difference?

A

Declarative languages e.g. SQL contain code that describes the goal/operation that needs to be achieved but not how to achieve it.

Imperative languages use code that clearly specifies the actions to be performed in order to solve a problem.

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

What are the 2 main imperative types of programming language?

A

procedural
object oriented

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

What is a procedural language?

A

A language that solves a problem by carrying out a series of instructions step by step. e.g. python

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

What is an object oriented language?

A

A language that is based on objects of different classes that have methods and attributes. e.g. JavaScript

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

When is OOP better suited in general?

A

Problems where we can represent real life entities with objects or higher scale complex software.

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

What are the 4 programming constructs and what do they mean?

A

sequence - line by line execution of code

selection - block of code ran based on a condition

iteration - block of code ran repetitively based on a condition or for a set number of times (count or condition controlled)

recursion - when a function calls itself until a certain condition is met which returns a different value

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

What is the opcode?

A

The type of instruction to be performed.

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

What is the operand?

A

The data or address upon which the instruction is performed.

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

What are 4 memory addressing modes?

A

immediate addressing
direct addressing
indirect addressing
indexed addressing

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

What is immediate addressing?

A

When the operand is the actual value that the opcode is performed on.

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

What is direct addressing and why is it used?

A

When the operand is the address of the location in memory that contains the data upon which the instruction is performed.

This is used to represent higher numbers as memory has access to more bits than the operand.

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

What is indirect addressing and why is it used?

A

When the operand is the address in memory that stores another memory address that is the location of the data upon which the instruction is performed.

This is used to access more memory addresses as memory can represent more bits than the operand.

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

What is indexed addressing and when is it used?

A

The operand is added to the value in the index register to produce the memory address of the location of the data that the instruction is performed on.

This is used for arrays as the index register stores an offset that represents the start of the array so that the data can be stored contiguously.

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

What is a class?

A

A template for defining methods and attributes, used to create objects.

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

What is an object?

A

A single instance of a class that can have its own values for the class’ attributes.

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

What is a method?

A

A function that belongs to a class and carries out something that the class can do.

17
Q

What is an attribute?

A

A specific property of a class that is stored as a variable.

18
Q

What is the constructor method?

A

The function used to create a new instance of a class.

19
Q

What is the difference between private and public methods/attributes?

A

Private can only be accessed within the scope of the object whereas public can be accessed from outside of the object.

20
Q

What is encapsulation?

A

When private attributes can only be accessed and changed via public methods.

21
Q

What is the purpose of encapsulation?

A

Reduces chance for bugs and unintended side effects as an instance’s attribute values can’t be edited unless using a preprogrammed method.

22
Q

What are get and set methods (getters and setters)?

A

Public methods that are used to get or set private attributes.

23
Q

What is inheritance?

A

When a class takes on the methods and attributes of a parent class but can override some of these or be given additional methods and attributes.

24
Q

What is polymorphism?

A

When an object can take on more than one form.

25
Q

What are the advantages of OOP?

A

high level of reusability through inheritance

classes can be used across multiple projects

encapsulation makes the code more reliable

modular structure is easy to update and maintain

high level of abstraction and classes can be reused saving time and effort

26
Q

What are the disadvantages of OOP?

A

when few components are reused, OOP may be a long and inefficient solution compared to procedures

OOP isn’t very useful for smaller problems