Week 2 Flashcards

1
Q

What is a data type?

A

A type is a set of values and operations that are permitted on the values.

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

What are the two kinds of types?

A

A value type and a reference type.

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

Whats an example of a value type?

A

int x = 5

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

What’s an example of a reference type

A

string str = “hello”

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

Where is the actual data stored for a reference type?

A

In the heap.

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

Where is the reference stored for a reference type?

A

In the stack (value types are also found in the stack)

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

What are some examples of a value type?

A

int, double, long, char, bool, decimal

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

What are some examples of a reference type?

A

objects, strings, lists (any classes as well)

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

What’s a field?

A

a field stores data within a class

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

What’s a property?

A

Looks and acts like a field however it does not allocate memory for data.
ex:
class Demo
{ private int theRealValue; //a field
public int MyValue //a property
{
set{ theRealValue = value; }
get{ return theRealValue; }
}
}

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

What return type do set statements have?

A

a void return type

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

What return type do get statement have?

A

returns a value of the type of the property

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

What’s a method?

A

A block of code thar can be executed (or called).

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

What’s a constructor?

A

A kind of method, that is used to initialize the state of a class instance.

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

What is an access modifier?

A

The access modifier optionally specifies what other part of the program can access the member. (ex. public, private)

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

Where can private members be accessed?

A

Within the class in which they are declared.

17
Q

Where can public members be accessed?

A

Throughout the entire program.

18
Q

How do you instantiate a string, from a char array called “chars”?

A

string str = new string(chars);

19
Q

Are strings immutable?

A

Yes

20
Q

What does the StringBuilder class do?

A

Helps us produce strings while reducing the number of copies being made. It is mutable.

21
Q

What namespace does the StringBuilder class use?

A

using System.Text;

22
Q

What symbol is necessary to write an interpolated string.

A

$

23
Q

OOP supports information hiding by using private fields, what is this called?

A

Encapsulation

24
Q

What is concept of inheritance?

A

Types can be derived from other types, a type can be a subtype.

25
Q

What is polymorphism?

A

The ability of an object to take on many forms.

26
Q

What namespace do lists use?

A

using System.Collections.Generic;