Week 2 Flashcards
What is a data type?
A type is a set of values and operations that are permitted on the values.
What are the two kinds of types?
A value type and a reference type.
Whats an example of a value type?
int x = 5
What’s an example of a reference type
string str = “hello”
Where is the actual data stored for a reference type?
In the heap.
Where is the reference stored for a reference type?
In the stack (value types are also found in the stack)
What are some examples of a value type?
int, double, long, char, bool, decimal
What are some examples of a reference type?
objects, strings, lists (any classes as well)
What’s a field?
a field stores data within a class
What’s a property?
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; }
}
}
What return type do set statements have?
a void return type
What return type do get statement have?
returns a value of the type of the property
What’s a method?
A block of code thar can be executed (or called).
What’s a constructor?
A kind of method, that is used to initialize the state of a class instance.
What is an access modifier?
The access modifier optionally specifies what other part of the program can access the member. (ex. public, private)