final Flashcards

(56 cards)

1
Q

The using directive has three uses:

A

Tells the compiler where to look for a class that is used in the Application

  1. To allow the use of types in a namespace so that you do not have to qualify the use of a type in that namespace: using System.Text;
  2. To allow you to access static members of a type without having to qualify the access with the type name
  3. To create an alias for a namespace or a type.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

White space – space bar, tab, blank lines

A

white space DOES NOT MATTER to the compiler.

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

Public class, naming conventions for identifiers: letters, digits underscores

A

no spaces allowed when naming a variable, method, or class!

Class and method names should always have a capitalized first letter!

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

write

A

keeps everything on one line

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

writeLine

A

finishes the method execution by moving to the next line

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

\n

A

move to next line

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

\t

A

tab

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

\r

A

‘carriage return’(moves cursor to beginning of current line)

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

Using variables, data types

Reading in variables

A

Console.readLine( );
- or if you’re assigning it -
varType varName = Console.readLine( );
int x = Console.ReadLine( );

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

/

A

returns the last whole number after a division operation

11/5 = 2

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

%

A

returns the remainder after a division operation

11%5 = 1

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

Simple Data types

A

int (short,long, etc.), bool, char, double, decimal

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

Complex Data types

A

String, and any other user-created object(like the account class from assignment 5)

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

Order of Operations

A

=, !=, , <=, >=

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

Building a class

A
public class Blah
	     {
		constructor, methods, whatev;
	     }
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

creating an object of a class in another class

A

Account whatev= new Account(parameters go here if you need any);

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

calling a method of the class

A

ClassName.Method(method params);

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

Instance Variable

A

a variable declared in a class that each object of that class has a copy of

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

Public properties

A

a variable with methods defined to access and modify its variable

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

Auto-implemented Property

A

public double TotalPurchases { get; set; };

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

Constructor

A
public ClassName(*params)
		       {
	       } -Used to ‘construct’ an instance of a class
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
22
Q

Method

A

public return type name(params)
ex. public int x (parameters)
{
}

-Used to run specific operations, functions, or procedures on an object

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

If-else

A
If (logical condition)
{
	*do this stuff*
}
else
{
	*do this other stuff*
}
24
Q

Nesting

A

using a second if-else structure inside an if statement. Similar to nested for loops

25
Conditional operator
Syntax: expression ? expression : expression • The first operand is implicitly converted to bool. It is evaluated and all side effects are completed before continuing. • If the first operand evaluates to true (1), the second operand is evaluated. • If the first operand evaluates to false (0), the third operand is evaluated. The result of the conditional operator is the result of whichever operand is evaluated — the second or the third. Only one of the last two operands is evaluated in a conditional expression.
26
While loops Structure
while(condition) { *do this stuff* }
27
Sentinel While loops Structure
using a target value to tell the loop to stop ``` EX: Int count=0; while(count <11) { count++; } ``` **This loop checks count, sees if it’s less than 11, and if it is, adds one to it. This will loop 10 times, and count is considered the “sentinel” value.
28
Casting
Forcing a variable to be compiled as another type of data. ``` double x = 1234.7; int a; // Cast double to int. a = (int)x; ```
29
Arithmetic compound operators
+= (any two operators used together)
30
Increment operators
++ (adds one to a value)
31
decrement operators
-- (takes one away from a value)
32
For
This is just a basic for loop structure, they can vary some For(int i=0; i
33
Switch
``` int caseSwitch = 1; switch (caseSwitch) { case 1: Console.WriteLine("Case1"); break; ``` case 2: Console.WriteLine("Case 2"); break; default: Console.WriteLine("Default case"); break; }
34
Break
used to break out of a loop earlier than stated
35
Continue
used to move on to the next iteration of a loop without executing the commands inside the loop
36
Logical operators
& & (AND) || (OR) ! (NOT)
37
Syntax Error
- You messed up the rules of the language | - misspelled words, forgetting a semicolon, etc.
38
Run-Time Error
- User enter a value that breaks your code | - ex. Compiler expects an int and they enter a string
39
Logical Error
Syntax is fine, and the code executes, but the output is not what is expected.
40
Header
the return type and name of the method public void Main (string[ ] args) header (header parameters)
41
Parameters
values or objects passed to the method that it needs to function correctly
42
Body
the list of statements inside the curly braces that tells the method how to operate
43
Calling methods from the same class
MethodName(params);
44
Calling methods from a different class
you have to declare an object first, then Gradebook mygb = new gradebook object.MethodName(params);
45
Scope of variables Instance
Can be seen throughout the class
46
Scope of variables local
Can be seen in the method it was declared in
47
Scope of variables parameter
Can be seen and used by the method it was passed to
48
Shadowing
``` Using the same name for a local variable and a parameter. IT IS BAD PRACTICE. However, it can be done, using the keyword ‘this’. EX: public Employee(string name, string alias) { // Use ‘this’ to qualify the fields, name and alias this.name = name; this.alias = alias; ```
49
Implicit conversion
occurs when setting a small data type to a larger data type. This is possible because there will be no loss of accuracy, since it’s essentially just providing more space to keep the number in. An example would be storing an int in a variable of type long. *Can also be referred to as a widening conversion
50
Random class
(rn.next(10), rn.next(1,10), 5+rn.next(10), 5* rn.next(10))
51
.next
returns a non-negative random integer less than the given value
52
Method overloading
Creating more than one method with the same name. They must have different parameters though!
53
Pass by Value
passes a copy of the original value (used for primitives)
54
Pass by Reference
passes the reference to the memory location storing a value (used for objects)
55
what are properties
- Properties manipulate the attributes that belong to a particular object of the class - properties are used to manipulate an object’s attributes.
56
random numbers
int randomValue = randomNumbers.Next(1, 7)