10. Principles of programming Flashcards

1
Q

What are the 5 paradigms?

A
  • event driven (imperative)
  • mark up (declarative)
  • procedural (imperative)
  • object oriented
  • visual
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the event driven paradigm?

A

The flow of the program is determined by external events. The program will remain in a loop state, waiting for user input. When an action occurs, a function will process that action. They use trigger functions to select which event handler to run, depending on what event has occurred.

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

What is the mark up paradigm?

A

Mark up languages add commands to text documents. These commands give instructions to an application reading the file on how to display and interpret the text. Commands are opened and closed so that any text written within them have that format applied to it.

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

What is the procedural paradigm?

A

Procedural languages work top to bottom and follow ordered instructions. Statements can be used to change the state of the program, e.g. selection and iteration.

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

What is the visual paradigm?

A

Visual languages make use of intuitive user interfaces to help build programs. It requires the programmer to think logically, rather than being able to write syntax.

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

What is the object oriented paradigm?

A

Objects are used as the building blocks of the software. An object is a unit that contains data and code, which is defined by it’s class.

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

What is a class?

A

A template for an object which defines it’s attributes and methods.

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

What is a method?

A

A programmed behaviour that is included in an object of a class. It can only access data within its own object. They carry out specific tasks on data within an object (private) or from another part of a program (public).

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

What are the access modifiers?

A

protected

+ public
- private
(hashtag) protected

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

Give a private attribute called amount of type real.

A
  • amount : Real
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Give a public method called getID that returns an integer.

A

+ getID() : Integer

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

Give a protected method called setName that accepts a string parameter.

A

(hashtag) setName(String)

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

What is encapsulation?

A

Encapsulation is the hiding of the implementation of a class and controlling access to it’s methods and attributes.

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

What is inheritance?

A

When a new object takes on the properties of an existing object. A subclass inherits from a superclass.

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

What is polymorphism?

A

When a general object is created that can be used with a wide range of data types.

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

What is abstraction?

A

When complex details are hidden from a user which does not need to know them, e.g. a driver needs to know how to use the accelerator and brakes but not the intricate mechanics of a car.

17
Q

How do high level languages and low level languages compare?

A

high level:
- easier to understand and code
- each line translates into multiple levels of machine code
- less control of the hardware
- allows for powerful commands that can perform complex tasks
- instructions are semantic

low level:
- more efficient than high level
- requires for less translation into machine code
- generally results in smaller executable programs
- allows developer to manipulate the CPU directly

18
Q

When is it suitable to use high level languages vs low level languages?

A

High level languages are used when execution speed is not the most critical factor, such as most modern programs.
Low level languages are used when execution speed is critical, such as device drivers.