A2 Chapter 13. Data Representation Flashcards

1
Q

What is a variable in programming?

A
  • A named location in memory used to store data.
  • The value of a variable can change during program execution.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a constant in programming?

A
  • A named location in memory with a value that cannot be changed during program execution.
  • Used to store fixed values.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are data types in programming?

A
  • Categories of data that define the operations that can be performed on the data and the way the data is stored.
  • Examples: Integer, Float, String, Boolean.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What is an array in programming?

A
  • A collection of elements of the same data type, stored in contiguous memory locations.
  • Accessed using an index.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is a function in programming?

A
  • A block of code designed to perform a specific task.
  • Can be reused multiple times in a program.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is the difference between a procedure and a function?

A
  • Procedure: A block of code that performs a task but does not return a value.
  • Function: A block of code that performs a task and returns a value.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is recursion in programming?

A
  • A technique where a function calls itself to solve smaller instances of the same problem.
  • Used in problems like factorial calculation, Fibonacci sequence.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What are control structures in programming?

A
  • Constructs that control the flow of execution in a program.
  • Types: Sequence, Selection (if-else), Iteration (loops).
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a loop in programming?

A
  • A control structure that repeats a block of code as long as a specified condition is true.
  • Examples: For loop, While loop.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the purpose of an if-else statement?

A
  • A control structure used to execute different blocks of code based on a condition.
  • Allows decision-making in a program.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is a switch/case statement?

A
  • A control structure that allows a variable to be tested for equality against a list of values.
  • Executes the block of code corresponding to the matching case.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What is the difference between a for loop and a while loop?

A
  • For loop: Executes a block of code a specific number of times.
  • While loop: Executes a block of code as long as a condition is true.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is a nested loop?

A
  • A loop inside another loop.
  • The inner loop is executed completely for each iteration of the outer loop.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

What is an exception in programming?

A
  • An error that occurs during the execution of a program.
  • Can be handled using try-catch blocks to prevent program crashes.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is the purpose of debugging?

A
  • The process of finding and fixing errors or bugs in a program.
  • Ensures the program runs correctly and efficiently.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is object-oriented programming (OOP)?

A
  • A programming paradigm based on the concept of objects.
  • Objects are instances of classes, which can contain data (attributes) and methods (functions).
17
Q

What are the four main principles of OOP?

A
  • Encapsulation: Hiding the internal state of an object and requiring all interaction to be performed through an object’s methods.
  • Abstraction: Hiding complex implementation details and showing only the necessary features.
  • Inheritance: A mechanism for creating a new class using the properties and methods of an existing class.
  • Polymorphism: The ability to present the same interface for different underlying forms (data types).
18
Q

What is a class in OOP?

A
  • A blueprint for creating objects.
  • Defines the attributes and methods that the objects created from the class will have.
19
Q

What is an object in OOP?

A
  • An instance of a class.
  • Contains data (attributes) and methods (functions) to manipulate that data.
20
Q

What is the difference between compile-time and run-time errors?

A
  • Compile-time errors: Errors detected by the compiler during the translation of source code to machine code.
  • Run-time errors: Errors that occur during the execution of a program.
21
Q

What is a constructor in OOP?

A
  • A special method used to initialize objects of a class.
  • Called automatically when an object is created.
22
Q

What is inheritance in OOP?

A
  • A mechanism that allows one class to inherit properties and methods from another class.
  • Promotes code reuse and hierarchical class relationships.
23
Q

What is method overloading?

A
  • A feature in OOP where multiple methods in the same class have the same name but different parameters.
  • Allows different ways to call a method depending on the input.
24
Q

What is method overriding?

A
  • A feature in OOP where a subclass provides a specific implementation of a method already defined in its superclass.
  • Allows a subclass to provide a specific behavior for a method.
25
Q

What is a try-catch block?

A
  • A structure used to handle exceptions in a program.
  • The code in the try block is executed, and if an exception occurs, the code in the catch block is executed.
26
Q

What are the two types of data types and explain the difference?

A
  1. Non-composite which can be defined without referencing another data type
  2. Composite which refers to other data types in its definition
27
Q

Pseudo code syntax for an enumerated data type

A

TYPE <identifier> = (value1, value2, value3, ... )
Note
1. Type names usually begin with T to aid the programmer</identifier>

  1. The values are not strings so are not enclosed in quotation
28
Q
A