TOPIC 1 MAIN

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/66

encourage image

There's no tags or description

Looks like no tags are added yet.

Last updated 1:34 PM on 4/7/26
Name
Mastery
Learn
Test
Matching
Spaced
Call with Kai

No analytics yet

Send a link to your students to track their progress

67 Terms

1
New cards

Why is it a good practice to use local variables? 3 Reasons

it makes a subroutine self contained;

memory allocated to local variables can be reused when subroutine not in use;

able to debug subroutine independently

2
New cards

State two differences between local and global variables.

global variables accessible to all parts of the program, local variables are only within the subroutine; global variables exist the entire time the program is running, local variables only exist when the subroutine they are in is executing

3
New cards

Explain the differences between definite and indefinite iteration.

definite iteration: the number of iterations is known at the time of execution;

indefinite iteration: the number of iterations depends on a condition (that is tested before / after each iteration)

4
New cards

Explain what exception handling is used for (2 reasons)

to stop a program from crashing; to deal with a run-time error

5
New cards

Subroutine (procedure/function)

A named ‘out of line’ block of code that may be executed (called) by simply writing its name in a program statement. It can be reused multiple times within a program.

6
New cards

Describe two advantages of re-using subroutines.

Saves time as code can be written once and called in many places; Reduced storage space of source code

7
New cards

Recursion

A recursive subroutine is one that has a call to itself as part of its execution.

8
New cards

Base case

A base case is a value that will not cause a recursive call and therefore allow the recursion to complete (and backtrack).

9
New cards

State four components of a stack frame.

return address; local variables; parameters; register values

10
New cards

Stack frame

A stack frame is a portion of the stack memory used with subroutine calls to store:

• return address

• parameters

• local variables.

A stack frame allows us to move to a subroutine call and then return to where we were called from and carry on.

11
New cards

What is the purpose of a hierarchy chart? (2 reasons)

To represent the structure of the program; To aid decomposition of a problem

12
New cards

Hierarchy chart

A hierarchy chart is a diagram that represents the structure of a program. Each subroutine is shown as a rectangle, and the hierarchy shows how subroutines are called from others.

13
New cards

Programmers are encouraged to adopt a structured approach to writing programs. Explain four reasons for adopting the structured approach.

code is easier to understand;

easier to debug and maintain;

can break problems down into sub-tasks;

can re-use subroutines

14
New cards

Structured approach to program design

The structured approach to program design involves breaking down problems into sub-problems. Code is then organised into subroutines.

15
New cards

Explain the difference between protected and private attributes.

Private attributes can only be accessed by the class they belong to whereas protected attributes can also be accessed by any classes that inherit from the class they belong to

16
New cards

Polymorphism

Polymorphism is the concept that different objects can respond to the same method call in different ways based on their class.

17
New cards

Explain the difference between an attribute that has a public specifier and an attribute that has a protected specifier

public means it can be accessed outside of the class it is in; protected means it can be accessed in the class it is in and any subclasses

18
New cards

Overriding

An overridden method has the same name as a method from an inherited class but a different implementation.

19
New cards

Describe two differences between a virtual method and an abstract method

virtual methods do not have to be overridden whereas abstract methods must be overridden by the derived class;

virtual methods contain code (with functionality) wheras abstract methods contain no code (with functionality)

20
New cards

Explain one difference between a local variable and a private class attribute.

A local variable can only be used in the subroutine in which it is declared whereas a private attribute can be accessed anywhere in the class;

21
New cards

Pointer/Reference

A pointer is an object (variable) that stores a memory address. By following a pointer, we can access the value stored at that location – this is known as dereferencing.

22
New cards

Records

A record is a composite data structure and allows for a collection of fields to be grouped together.

23
New cards

State two reasons why many programmers follow the design principle “favour composition over inheritance”

easier to test each class using unit testing; there can be unintended side effects for derived classes if a method in the base class is altered

24
New cards

Aggregation

A type of association where the aggregated object has a weaker form of association with the objects that it is aggregating than is the case with composition. These objects have an existence independent of the aggregated object and can continue to exist even after the aggregated object is disposed of.

25
New cards

Composition

A type of association where the relationship is stronger. If the containing object is destroyed, the associated object is also destroyed.

26
New cards

Describe the relationships aggregation and composition, making it clear what the difference between the two is

composition and aggregation are both ‘has a’ relationships, when an object contains another object; with composition if the containing object is destroyed so are the objects it contains, this is not the case with aggregation

27
New cards

User-defined data type

A custom data type created by the user combining existing data types.

28
New cards

Name two advantages of using constants over hard-coded values

Constants can be given identifier names, making code easier to understand;

updating a value only needs changing in one place

29
New cards

Constant

An identifier that represents a memory location that can store a value. This value cannot change during execution of a program. Note: Python does not have constants, but convention is that an identifier in capitals should indicate the concept of a constant.

30
New cards

Encapsulation

Combining of properties (data) and methods (procedures/functions) together into a class, where the way in which the data is stored, and the methods are carried out is hidden from other classes.

31
New cards

Inheritance

The relationship between two object types in which one is a kind of the other and shares some of its properties or behaviours.

32
New cards

Name three object-oriented design principles

encapsulate what varies;

favour composition over inheritance;

program to interfaces, not implementation

33
New cards

Encapsulate what varies

The separation of code that might need to be constantly changed. Areas of code that might need to be changed can be encapsulated behind an interface. Then, when any changes are needed, software written to use the interface does not need to be changed.

34
New cards

Favour composition over inheritance

The principle that programmers should look to use composition over inheritance when looking at concepts such as polymorphism.

35
New cards

Program to interfaces, not implementation

The principle that programmers should look to communicate between parts of a program by using an interface rather than the knowledge of an implementation.

36
New cards

What error will occur if a recursive subroutine never meets its base case?

Stack overflow

37
New cards

Parameter (of subroutine)

Parameters define the data to be passed to a subroutine.

38
New cards

Subroutines with interfaces

A subroutine interface is the method of passing data in and out of a subroutine.

39
New cards

Class diagram

A class diagram shows the relationship between classes in a program. Class diagrams involve single inheritance, composition (black diamond line), aggregation (white diamond line), public (+), private (-) and protected (#) specifiers.

40
New cards

Data type

Each variable has a data type. The data type determines what type of value the variable will hold, and the set of operations allowed.

41
New cards

Integer

A whole number.

42
New cards

Real/Float

Numbers that can include fractions/values after the decimal point.

43
New cards

Boolean

A data type that can represent the two values True and False.

44
New cards

Character

Stores a single character in a fixed-length format related to a specific character set (for example ASCII).

45
New cards

String

A string is a sequence of characters.

46
New cards

Date/Time

A date and time data type stores values such as a calendar date and time of day. Typically, a data type that is available in databases.

47
New cards

Arrays (lists)

An array is a collection of elements, each accessed using an index (and all elements must be of the same data type).

(Note: a list is typically dynamic and can have its size changed during runtime but an array is usually static and has a defined size.

Note: in Python, lists may contain elements of multiple data types.)

48
New cards

Variable

An identifier that represents a memory location that can store a value. This value can change during execution of a program.

49
New cards

Constant declaration (examples)

C# const int Months = 12; VB Const Months As Integer = 12 Python MONTHS = 12 Java final int MONTHS = 12;

50
New cards

Assignment

An assignment statement sets the value of a variable/constant.

51
New cards

Iteration

Iteration is the repetition of a block of code.

52
New cards

Selection

A selection statement allows blocks of code to be executed only when a certain condition is satisfied. Examples of selection statements include: IF THEN ELSE SWITCH/CASE/MATCH

53
New cards

Nested (selection/iteration)

When an iteration statement appears inside another iteration statement it is considered nested. When a selection statement appears inside another selection statement it is considered nested.

54
New cards

Meaningful identifier names

Meaningful identifier names make code easier to understand and maintain as the name describes the purpose of the variable or subroutine.

55
New cards

Integer division

The process of dividing two integers and gaining a result which is also an integer. Example: 10 // 3 = 3

56
New cards

Integer remainders

While integer division discards the remainder, this can still be a useful value. The remainder can be obtained by using the modulo operator. Example: 10 % 3 = 1

57
New cards

Exponentiation

Exponentiation refers to the repeated multiplication of a base number by a certain amount of times (the power). Examples: C# Math.Pow(b, n); VB Math.Pow(b, n) Python b ** n Java Math.pow(b, n);

58
New cards

Rounding

Rounding refers to replacing a number with an approximate simpler value. This is often a whole number but could be a number with a fixed number of decimal places.

Example: round(2.5)

59
New cards

Truncation

Truncation refers to shortening something. It usually refers to removing digits from a number. Examples: C# Math.Truncate(2.5); VB Math.Truncate(2.5) Python math.trunc(2.5) Note: there is no specific truncate method in Java, but truncation can be done using a combination of other methods, such as floor() and ceil().

60
New cards

Random number generation

The use of algorithms to produce sequences of numbers that appear unpredictable.

61
New cards

Programming paradigm

A programming paradigm is a particular approach to writing programs.

62
New cards

Procedural

A programming approach that is based on the use of procedures and functions.

63
New cards

Object-oriented

The object-oriented paradigm makes use of objects as containers of both properties (data) and methods.

64
New cards

Class

A class defines methods and attribute fields that capture the common behaviours and characteristics of objects.

65
New cards

Object

Objects based on a class are created using a constructor (implicit or explicit) and a reference to the object assigned to a reference variable of the class type.

66
New cards

Instantiation

Creating an instance of a class (creating an object from a class).

67
New cards

Association

An association is a relationship between two classes. There are different types of association: composition and aggregation.

Explore top notes

note
APUSH FALL EXAM REVIEW
Updated 474d ago
0.0(0)
note
Institutional Review Boards
Updated 1414d ago
0.0(0)
note
Periodic Table and Trends
Updated 577d ago
0.0(0)
note
18th & 19th century Britain
Updated 719d ago
0.0(0)
note
Plate Tectonics
Updated 1770d ago
0.0(0)
note
APUSH FALL EXAM REVIEW
Updated 474d ago
0.0(0)
note
Institutional Review Boards
Updated 1414d ago
0.0(0)
note
Periodic Table and Trends
Updated 577d ago
0.0(0)
note
18th & 19th century Britain
Updated 719d ago
0.0(0)
note
Plate Tectonics
Updated 1770d ago
0.0(0)

Explore top flashcards

flashcards
ASD 2: Cap. 7
49
Updated 1189d ago
0.0(0)
flashcards
Preliminary Chapter
84
Updated 950d ago
0.0(0)
flashcards
Spanish 4 - 7A
46
Updated 412d ago
0.0(0)
flashcards
Unit 4 Module 26
20
Updated 778d ago
0.0(0)
flashcards
100 most common spanish words
100
Updated 581d ago
0.0(0)
flashcards
Unit 1 Part 2 - Modules 4 - 8
40
Updated 817d ago
0.0(0)
flashcards
ASD 2: Cap. 7
49
Updated 1189d ago
0.0(0)
flashcards
Preliminary Chapter
84
Updated 950d ago
0.0(0)
flashcards
Spanish 4 - 7A
46
Updated 412d ago
0.0(0)
flashcards
Unit 4 Module 26
20
Updated 778d ago
0.0(0)
flashcards
100 most common spanish words
100
Updated 581d ago
0.0(0)
flashcards
Unit 1 Part 2 - Modules 4 - 8
40
Updated 817d ago
0.0(0)