programming for designers Flashcards

1
Q

What is a For loop?

A

For loops are control structures that iterate over a sequence of values or a block of code for a predetermined number of times.

for (statement 1; statement 2; statement 3)
{
// code block to be executed
}

Technically, for loops provide a concise way to express iteration, consisting of an initialization statement, a condition for continuation, and an iteration statement. Practically, they are useful when you know in advance how many times to execute a block of code, such as iterating through elements in an array.

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

What is a While loop?

A

While loops repeatedly execute a block of code as long as a specified condition is true.

while (condition)
{
// code block to be executed
}

Technically, while loops evaluate a condition before each iteration, executing the loop body if the condition is true. Practically, they are used when the number of iterations is not known in advance and depends on a certain condition.

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

What is a Foreach loop?

A

Foreach loops iterate over elements in a collection, such as an array or a list.

foreach (type variableName in arrayName)
{
// code block to be executed
}

Technically, foreach loops simplify iteration by automatically handling the traversal of a collection. Practically, they are useful for iterating through all elements in a collection without explicitly managing an index.

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

What are If/Else statements?

A

If/Else statements allow for decision-making in code based on whether a certain condition is true or false.

if (condition)
{
// block of code to be executed if the condition is True
}

Technically, if, else, and else if are control flow statements that direct the program’s execution based on the evaluation of conditions. Practically, they are essential for implementing logic and responding to different scenarios in a program.

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

What is a class?

A

A class holds related information, actions, and behaviors inside a single container.

class Car
{
string color = “red”;

static void Main(string[] args)
{
Car myObj = new Car();
Console.WriteLine(myObj.color);
}
}

Technically, classes are data structures containing variables, methods, and other programmatic information. Practically, a class is a blueprint that sets out the rules for any object created using it.

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

What is a method?

A

Methods are how work gets done in an application.

static void MyMethod()
{
Console.WriteLine(“I just got executed!”);
}

static void Main(string[] args)
{
MyMethod();
}

Technically, a method is a block of code containing executable statements that run when called by name, and can take in arguments. Practically, a method is a container for instructions that run every time executed, which can also take in variables as inputs.

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

What is a variable?

A

A variable is the most basic unit of programming, as an atom is to the physical world.

Technically, a variable is a section of memory that holds an assigned value, tracking its information, value, and type. Practically, a variable is a container that can be created, filled, moved, and referenced as needed.

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

What is an Int variable?

A

Int variables store whole numbers without decimal points, representing integers.

Technically, int is a data type in C# for integer values, allocating 32 bits of memory. Practically, int variables are used for counting, indexing, and representing discrete quantities.

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

What is a Float variable?

A

Float variables store numbers with decimal points, representing floating-point numbers.

Technically, float is a data type in C# for single-precision floating-point numbers. Practically, float variables are suitable for values that can have fractional parts.

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

What is a Bool variable?

A

Bool variables store either true or false, representing binary conditions.

Technically, Bool is a data type in C# for Boolean values, using one bit of memory. Practically, Bool variables are essential for implementing decision-making and conditional logic.

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

What is a String variable?

A

String variables store sequences of characters, representing text.

Technically, string is a data type in C# for representing text, enclosed in double quotes. Practically, string variables are widely used for handling and manipulating textual data.

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

What is Git?

A

Git is a code collaboration tool that supports branching and merging operations.

Practically, branching allows developers to work on independent features or fixes, while merging combines changes from different branches, facilitating parallel development.

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

What are Arrays?

A

Arrays are ordered collections of elements, each identified by an index or a key.

Technically, in C#, arrays are fixed-size structures that store elements of the same data type. Practically, they are used for organizing and efficiently accessing related values.

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

What are Lists?

A

Lists are dynamic collections of elements that can be resized during runtime.

Technically, C# provides the List<T> class for dynamic arrays with useful methods. Practically, lists are versatile, suitable for scenarios where the number of elements may change frequently.</T>

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

What are Dictionaries?

A

Conceptually: Dictionaries store key-value pairs, allowing efficient retrieval of values based on unique keys.
Technically: C# dictionaries, represented by the Dictionary<TKey, TValue> class, provide fast access to values using keys.
Practically: Dictionaries are valuable for implementing associative arrays, lookup tables, and efficient data retrieval.

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

What is Encapsulation?

A

Technically, it is achieved through access modifiers in C#. Practically, it promotes data hiding and enhances code organization.

Public - Acessible outside the class
Protected - Acessible to the class and deprived from the class
Private - Not accessible outside of the class

17
Q

What is Inheritance?

A

Inheritance is the OOP concept where a subclass inherits properties from a superclass.

class Vehicle // base class (parent)
{
public string brand = “Ford”; // Vehicle field
public void honk() // Vehicle method
{
Console.WriteLine(“Tuut, tuut!”);
}
}

class Car : Vehicle // derived class (child)
{
public string modelName = “Mustang”; // Car field
}

Technically, class DerivedClass : BaseClass syntax is used in C#. Practically, it facilitates code reuse and creates a hierarchy of classes.

18
Q

What is Polymorphism?

A

Polymorphism allows objects to be treated as instances of their parent class.

class Animal // Base class (parent)
{
public virtual void animalSound()
{
Console.WriteLine(“The animal makes a sound”);
}
}

class Pig : Animal // Derived class (child)
{
public override void animalSound()
{
Console.WriteLine(“The pig says: wee wee”);
}
}

Technically, it is achieved through method overriding and interfaces in C#. Practically, it simplifies code and promotes flexibility.

19
Q

What is an Interface?

A

Conceptually: Interfaces define a contract for classes, specifying a set of methods that implementing classes must provide.
Technically: In C#, interfaces are declared using the interface keyword, and classes implement them using :.
Practically: Interfaces facilitate code organization and multiple inheritance-like behavior while allowing different classes to share a common set of methods.

20
Q

What is an Object?

A

Conceptually: Objects are instances of classes, representing real-world entities with properties and behaviors.
Technically: Objects in C# are created using the new keyword, and they interact with each other through method calls and property access.
Practically: Objects are the core entities in OOP, enabling modeling and manipulation of complex systems.

Technically, they are created using the new keyword in C#. Practically, objects enable modeling and manipulation of complex systems.

21
Q

What is an Enum?

A

An enum is a special “class” that represents a group of constants (unchangeable/read-only variables).

To create an enum, use the enum keyword (instead of class or interface), and separate the enum items with a comma:

enum Level
{
Low,
Medium,
High
}

You can access enum items with the dot syntax:
Level myVar = Level.Medium;
Console.WriteLine(myVar);

Technically, enumerations are declared using the enum keyword. Practically, they improve code readability and maintainability.

22
Q

What is an Algorithm?

A

Software Design: Algorithm
Conceptually: An algorithm is a step-by-step procedure or set of rules for solving a specific problem or performing a specific task.
Technically: Algorithms are implemented using programming constructs like loops, conditionals, and mathematical operations.
Practically: Designing efficient algorithms is crucial for optimizing the performance of software applications.

23
Q

What is an Accessor?

A

An accessor is a method or property that provides read access to an object’s internal state.

Technically, accessors are often implemented using properties in C#. Practically, they are essential for maintaining encapsulation.

24
Q

What is a Mutator?

A

A mutator is a method or property that allows modification of an object’s internal state.

Technically, mutators are often implemented using properties or methods in C#. Practically, they are crucial for maintaining encapsulation.

25
Q

What is a Singleton?

A

Singleton is a design pattern that ensures a class has only one instance.

Technically, it is implemented using a private constructor and a public static method in C#. Practically, singletons are useful for managing configuration settings or resource pools.

26
Q

What is an Observer?

A

Observer is a design pattern where an object maintains a list of dependents that are notified of state changes.

Technically, it can be implemented using interfaces and events in C#. Practically, observers facilitate a loosely coupled way of managing dependencies.