Programming Fundamentals Flashcards

1
Q

What is the structure to specify a new variable?

A

Type Identifier = Value

i.e int myAge = 30;

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

What syntax is used to create a variable without specifying its type?

A
var
i.e var name1 = "John"
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

How do you write to console a sentence referencing variables using string interpolation?

A

Console.WriteLine($”Variable name is {varialbe}”)

$ calls variables enclosed in {} brackets

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

What is the procedure to redefine an existing variable?

A

Identifier = Value

You cannot reassign variable type once already defines

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

How do you write to console a sentence referencing variables without using string interpolation?

A

Console.WriteLine(“Variable name is {0} and age is {1}”, name, age)
You put the variables after the string which substitutes the values in {} brackets

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

What is the syntax for Boolean operators?

A

&& - and
|| - or
^ -xor

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

What is the most efficient way to increment a value by 1?

A

x++ /++x

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

What is the most efficient way to increment a value by more than 1?

A

x += 2

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

What is the syntax for comparison operators?

A
<
>
<=
>=
==
!=
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What is the construct of a for loop?

A
Initialisation, Test, Statement
for(int i = 0; i < 10; i++)
*Runs once regardless 
*Test is evaluated after statement is executed
*You must use i
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is the construct for a do while loop?

A

do
{
} while();

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

What is a do while loop?

A

Executes its code once regardless of of the statement boolean value

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

What is a constant?

A

Immutable assigned value, does not change

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

What is an enumerator?

A

A distinct type that contains set of constants, with a default value of 0 that increments by 1

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

What is the construct to create a constant?

A
const name1 = "Yarn"
Must specify const otherwise default is a variable
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is the construct for an enumerated constant

A
Create:
enum TransportMode{
Bicycle,
Car,
Train}

Call:
TransportMode.Train

17
Q

Where in the syntax are enumerated constants created?

A

Under the class program, referenced under Main method

18
Q

What is the value of an enumerated constant?

A

A string, the set of the enumerated constant

Must cast to an int to use the value of the constant

19
Q

What is a switch statement?

A

Allows you to pick a path of many, depending on the value, alternative to if statement

20
Q

What is the construct for forming a switch statement?

A
switch (position) {
case 1: //1 represents value of position
      ConsoleWriteLine("First Place")
      break;
default: ("None of the cases are true") }
21
Q

How do you create an array with 5 items?

A

int[] myA = int[5]

*first item will be index myA[0], last index myA[4]

22
Q

What is an “is a” relationship?

A

A class that inherits members from another