OOP Flashcards

(66 cards)

1
Q

What is the general nature of an object?

A

An object encapsulates data (state) and behavior (methods), with its own identity and is created from a class.

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

What is an abstract entity?

A

A generalized concept (like an abstract class or interface) that cannot be instantiated, and is used to define structure or behavior that other concrete classes must implement.

eg. “animal” is an abstract entity. You don’t see animals around, you see dogs, birds, cats, etc.

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

What is the difference between an object and an instantiation?

A

Instantiation is the process of creating an object from a class. An object is the result of that process—an actual instance of the class with its own state and behavior.

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

What is instantiation?

A

The process of creating an object from a class by calling its constructor, which allocates memory and initializes its attributes.

Example: Car myCar = new Car();

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

What is a UML (unified modelling language) diagram?

A

A standardized visual representation of a system’s classes, objects, and their relationships, used to model object-oriented programs.

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

What is the process of decomposition into several related objects?

A

It’s the process of dividing a complex problem or system into simpler, connected objects, where each object handles its own specific task.

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

What is dependency (‘uses’) in object-oriented programming?

A

A relationship where one class depends on another to function, typically by calling its methods or using its data temporarily.

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

What is aggregation (‘has a’)?

A

A relationship where one class contains or is composed of other classes, but those parts can exist independently of the whole.

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

What is inheritance (‘is a’)?

A

A mechanism where one class (subclass) inherits attributes and methods from another class (superclass), allowing code reuse and hierarchical relationships.

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

Why is it important to reduce dependencies in a given problem?

A

Dependencies increase maintenance overheads.

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

Why is it necessary to have different data types?

A

To accurately and efficiently represent and manipulate different kinds of data in a program. Each type defines the kind of values a variable can store, how much memory it uses, and what operations can be performed on it.

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

What is an integer?

A

A data type used to store whole numbers, both positive and negative, without decimals.

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

What is a real data type?

A

A data type used to store numbers with decimal (fractional) parts, including both positive and negative values.

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

What is a string?

A

A data type used to store a sequence of characters, such as letters, numbers, and symbols.

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

What is a boolean?

A

A data type that can store only two possible values: true or false.

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

What are parameters in programming?

A

Parameters are placeholders used in sub-programs (like procedures or functions) to receive data (input) from the part of the program that calls them.

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

How are data items passed to and from parameters?

A

Pass by value
When you pass a variable to a method, a copy of the value is passed — not the original.
So if you change it inside the method, the original doesn’t change.

🧠 Example: If you pass x = 5 to a function and the function changes it to 10, x is still 5 outside the function.
(There is another method called pass-by-reference but you don’t need to understand this)

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

What is encapsulation?

A

The concept of bundling data and methods that operate on that data into a single class, and restricting direct access to some components using access modifiers (e.g. private, public).

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

What is polymorphism?

A

Polymorphism allows objects of different classes to be treated as if they are of the same class, usually through shared methods.

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

What is method overloading?

A

Defining multiple methods with the same name but different parameters within the same class.

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

What is method overriding?

A

When a subclass provides a new implementation of a method inherited from its superclass, using the same method name and parameters.

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

What are the advantages of encapsulation?

A

The scope of data should be confined to the object in which it is defined as far as possible in order to limit side effects and dependencies

Keeps data protected from unauthorized access or accidental changes and improves code maintainability by controlling how data is accessed and modified.

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

What are the advantages of inheritance?

A

A parent object holds common data and actions, which enhances reuse and reduces maintenance overheads.

Promotes code reuse by allowing new classes to use existing class functionality and simplifies updates: changes in the parent class automatically affect child classes.

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

What are the advantages of polymorphism?

A

An action in a child object may choose to override actions of a parent object. This allows an external program to use the same action on a family of objects without knowing the implementation detail.

Improves flexibility and extensibility of code and enables generic code that works on objects of different types.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What are the advantages of libraries of objects?
Sorts and other complex algorithms and processes do not have to be “re-invented” Saves development time through reusable, pre-tested components and encourages consistency and reliability across projects.
26
What are the disadvantages of OOP?
Increased complexity for small problems. Can be more complex and harder to learn than procedural programming and may use more memory and processing power due to additional structures.
27
What is the use of programming teams?
Working in teams improves productivity, problem-solving, and allows members to specialize in different tasks (e.g. front-end, back-end, testing).
28
What is modularity in program development?
Modularity means dividing a program into separate, independent components (modules), each responsible for a specific task.
29
What are the advantages of modularity?
Makes code easier to understand, debug, and maintain; allows multiple developers to work on different parts of the program at the same time; promotes code reuse and easier testing.
30
What is a class?
A template or blueprint for creating objects. It defines the attributes (variables) and methods (functions) that the objects will have.
31
What is an identifier?
An identifier is the name you give to a class, object, method, or variable in code.
32
What is an instance variable?
A variable defined in a class but outside any method, and each object created from the class has its own copy. ie. one specific attribute or piece of data that belongs to a particular object.
33
What is a parameter variable?
A variable declared in a method signature to receive values when the method is called.
34
What is a local variable?
A variable that’s declared inside a method and only exists while that method is running — you can’t use it outside that method.
35
What is a method?
A function defined in a class that performs actions or returns values when called on an object.
36
What is an accessor (get method)?
A method that returns the value of an instance variable without changing it.
37
What is a mutator (set method)?
A method that changes the value of an instance variable.
38
What is a constructor?
A special method that is called when an object is created, used to initialize instance variables.
39
What is a method signature?
The combination of a method’s name and parameter list — used to identify the method.
40
What is a return value?
The output value that a method sends back after execution, if it is not void.
41
What does 'private' mean in access modifiers?
Accessible only within the same class.
42
What does 'protected' mean in access modifiers?
Accessible within the class, subclasses, and same package.
43
What does 'public' mean in access modifiers?
Accessible from any class.
44
What does 'extends' mean in class inheritance?
Keyword used when one class inherits from another class.
45
What does 'static' mean?
static means a variable or method belongs to the class itself, not individual objects, so it's shared across all objects, and any change to it affects all of them.
46
What is the int data type?
Stores integers.
47
What is the long data type?
Stores large integers.
48
What is the double data type?
Stores decimal values.
49
What is the char data type?
Stores a single character.
50
What is the boolean data type?
Stores true/false.
51
What are features of modern programming languages that enable internationalization?
Unicode for global text support and locale settings for date, time, and currency formats.
52
What are the ethical & moral obligations of programmers?
Ensure data privacy and security and avoid bias in algorithms.
53
What are selection statements in programming?
Selection statements let your program make decisions and choose what code to run based on conditions. Use if, if-else, or switch to control flow.
54
What are repetition statements in programming?
Use for, while, or do-while loops for repetition.
55
What are static arrays?
A static array is an array with a fixed size that cannot be changed after it is created. - Fixed-size collection of elements of the same type.
56
What is a primitive data type?
A primitive data type is a fundamental data type provided by a programming language to store simple values such as integers, characters, or booleans.
57
What is a method signature?
A method signature is the part of a method definition that includes the method’s name and the number and type of its parameters.
58
What is runtime error?
A runtime error is an error that occurs while the program is running, causing it to crash or behave unexpectedly. Examples include: * Dividing by zero * Accessing an invalid array index * Using a null reference These errors are not detected during compilation but only appear when the affected code is executed.
59
What is the purpose of "this."?
The purpose of this. is to refer to the current object’s instance variables or methods within a class. It is commonly used to distinguish between instance variables and parameters or local variables with the same name.
60
What is open source code?
Open source code is source code that is made freely available for anyone to view, use, modify, and distribute. Source code is the original human-readable code written by a programmer in a high-level programming language, such as Java or Python.
61
Ethical issues that may arise if modules are developped from open source code
* License violations: Reusing open source code without following its license terms (e.g., not crediting authors or failing to share modifications) can be unethical and possibly illegal. * Lack of attribution: Failing to acknowledge original developers disrespects their intellectual contributions. * Security risks: Using open source code without reviewing it may introduce vulnerabilities, impacting users' data and privacy. * Plagiarism: Claiming open source code as original work, especially in academic or professional settings, is dishonest.
62
What is a modifier?
A modifier is a keyword in programming used to change the properties or behavior of classes, methods, or variables. Common examples include: * public, private – control access (access modifiers) * static – indicates something belongs to the class, not instances * final – makes a variable constant or prevents method overriding
63
Aggregation vs inheritance
Inheritance: is_a Aggregation: has_a
64
What is the arrow type for: * uses (dependency) * has_a * is_a
uses: dashed arrow has_a: diamond arrow is_a: normal arrow
65
Object reference
An object reference is a variable that holds the memory address of an object, not the actual object itself.
66
Open source movement
The Open Source Movement is a social and technological shift focused on freely sharing software source code, so that anyone can view, modify, and distribute it.