Programming Technique II – Introduction to Programming Paradigms & OOP (SCSJ1023)

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/35

flashcard set

Earn XP

Description and Tags

Flashcards covering procedural, functional, and object-oriented paradigms; higher-order functions; OOP principles (encapsulation, data hiding, classes, objects, association, inheritance, polymorphism); and UML basics.

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

36 Terms

1
New cards

Which programming paradigm is the main focus of Programming Technique II (SCSJ1023)?

Object-Oriented Programming (OOP).

2
New cards

Which programming language is used in this course to teach OOP concepts?

C++.

3
New cards

Name three traditional procedural programming languages.

Any three of: C, Pascal, BASIC, Ada, COBOL.

4
New cards

In procedural programming, how are data and operations organized?

Data and the operations that act on them are separate; data are sent to procedures/functions.

5
New cards

Define functional programming in one sentence.

A paradigm where programs are built by applying and composing functions, treating functions as first-class citizens.

6
New cards

What does it mean for a function to be a ‘first-class citizen’ in functional programming?

It can be bound to names, passed as a parameter, and returned from other functions.

7
New cards

Which programming styles do procedural programming and OOP follow?

Imperative programming style (describing HOW a program operates).

8
New cards

Which style does functional programming follow, declarative or imperative?

Declarative – it specifies WHAT should be accomplished, not how.

9
New cards

What is a higher-order function?

A function that takes other functions as parameters and/or returns a function as its result.

10
New cards

What do we call a function passed into another function as an argument?

A callback function.

11
New cards

In C++, what is ‘function binding’?

Assigning a function’s address to a variable without invoking the function (e.g., auto g = getNumber;).

12
New cards

What does the function getFunctionByOperator(char oper) demonstrate?

Returning a function pointer based on an operator, showing that functions can be returned from functions.

13
New cards

What is a lambda function?

An anonymous inline function written directly where a callback is needed.

14
New cards

Give one practical use case of higher-order functions shown in the notes.

Iterating over an array with forEach to apply different printing or filtering behaviors.

15
New cards

In OOP, what are the data stored inside an object called?

Attributes or properties.

16
New cards

In OOP, what are the operations that manipulate an object’s data called?

Methods.

17
New cards

State the OOP concept that combines data and the methods that operate on that data into a single unit.

Encapsulation.

18
New cards

What is data hiding?

Restricting direct access to an object’s attributes so they can only be changed through its methods.

19
New cards

What is meant by a programming interface in OOP?

The set of public methods through which other objects interact with an object’s private data.

20
New cards

Define a ‘class’.

A blueprint or template that defines the attributes and methods common to all objects of a certain type.

21
New cards

Define an ‘object’.

An instance of a class created in memory during program execution.

22
New cards

Explain the relationship between a class and its objects.

A class defines properties and behaviors; objects are concrete instantiations of that definition.

23
New cards

What is an association in OOP?

A relationship linking objects of one class with objects of another, e.g., a Person owns many Cars.

24
New cards

Give two possible cardinalities of an association.

One-to-one, one-to-many, many-to-one, or many-to-many.

25
New cards

Define inheritance.

A mechanism allowing a class to extend or reuse code from another class, forming an ‘is-a’ relationship.

26
New cards

What is polymorphism?

The ability of different classes to respond differently to the same method call (perform the same action differently).

27
New cards

Give an everyday example illustrating polymorphism from the notes.

Grasshopper and Ant both ‘move’ but one jumps while the other crawls.

28
New cards

List one key difference between procedural programming and OOP.

PP separates data and functions, while OOP encapsulates them into objects.

29
New cards

What does UML stand for?

Unified Modelling Language.

30
New cards

What are the three sections of a UML class diagram box?

Class name, member variables (attributes), and member functions (methods).

31
New cards

In UML, what symbol denotes a private member?

A minus sign (–).

32
New cards

In UML, how do you indicate a public member?

A plus sign (+).

33
New cards

How is a data type shown for an attribute in UML?

AttributeName : DataType (e.g., width : double).

34
New cards

How is a parameter’s data type shown in UML?

ParameterName : DataType inside the parentheses of the method signature.

35
New cards

How is a function’s return type indicated in UML?

A colon and data type placed after the parameter list (e.g., getArea() : double).

36
New cards

How are constructors and destructors represented in UML with respect to return types?

They have no return type listed in the diagram.