Midterm review Flashcards

1
Q

Using Directive

A
  • Using System
  • tells the compiler where to look for a class that’s used in this app
  • Each using directive identifies a namespace containing predefined classes that a C# app should be able to use
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

White space

A
  • space bar, tab, blank lines
  • Ignored by the compiler
  • make code easier to read
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Class Name Convention

A
  • begin with a capital letter and capitalize the first letter of each word they include
  • a series of characters consisting of letters, digits and underscores (_) that does not begin with a digit and does not contain spaces
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Write

A
  • cursor stays on the same line of text in the console window
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

WriteLine

A
  • cursor moves to the next line of text in the console window
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

escape sequence

A
  • \n, \t, \r, ", \
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

\n

A
  • New line. Positions the screen cursor at the beginning of the next line
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

\t

A
  • Horizontal tab. Moves the screen cursor to the next tab stop
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

\r

A
  • Carriage return. Positions the screen cursor at the beginning of the current line—does not advance the cursor to the next line. Any characters output after the carriage return overwrite the characters previously output on that line.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

"

A
  • Double quote. Used to place a double-quote character (“) in a string—e,g., Console.Write( “"in quotes"” ); displays “in quotes”.
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

\

A

Backslash. Used to place a backslash character in a string.

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

declare a class named “Addition”

A

public class Addition

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

declare the main method

A

public static void Main(string [ ] args)
{

}

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

declare “number1” as an integer data type

A

int number1;

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

initialize number1 as an integer data type equal to 10

A

int number1 = 10;

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

convert “number1” to an Integer data type

A

number1 = Convert.ToInt32( Console.ReadLine ( ) );

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

Integer data types

A
  • byte
  • short
  • int
  • long
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
18
Q

floating point data types

A
  • float
  • double
  • decimal
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
19
Q

char data type

A
  • one character - “A”
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
20
Q

Bool data type

A
  • true / false

- yes / no

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

String data type

A

“my name is Krista”

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

Simple data types

A
  • int
  • float
  • char
  • bool
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
23
Q

complex data type

A

string

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

=

A
  • assignment oppertator

- reads right side first

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

Arithmetic Operators

A
  • Addition ( + )
  • Subtraction ( - )
  • Multiplication ( * )
  • Division ( / )
  • Remainder ( % ) -> Modulas
26
Q

Relational Operators

A

> , =, <=

higher Precedence

27
Q

Equality Operators

A

== , !=

lower Precedence

28
Q

get accessors

A
  • reading the values of a variable
29
Q

set accessors

A
  • string values in a variable
30
Q

create a Gradebook object of a Gradebook class in another class

A
  • Gradebook mygb = new Gradebook( );
31
Q

Call Gradebook’s DisplayMessage method

A

myGradebook.DisplayMessage( );

32
Q

new class all together

A
public class GradeBookTest
{
          public static void Main( string[] args )
{
         GradeBook myGradeBook = new GradeBook();
     myGradeBook.DisplayMessage(); }  }
33
Q

local variables

A
  • Variables declared in the body of a method

- can be used only in that method

34
Q

instance variables

A
  • When each object of a class maintains its own copy of an attribute
  • each object (instance) of the class has a separate instance of the variable
35
Q

public property

A

public class gradebook

36
Q

constructor

A
  • if you dont declare one it will automatically be assigned
  • public GradeBook( string cname )
    {
    CourseName = cname;
    }
37
Q

constructor characteristics

A
  • same name as class name
  • no return type
  • main method
38
Q

auto implemented property

A

public string CourseName { get; set; }

39
Q

selection

A
  • if (one option)
  • if / else (two options)
  • switch (more than two options)
40
Q

looping

A
  • while (counter and sentinel controlled)

- for

41
Q

counter

A

int counter = 1
While (Counter <= 22)
{
functions

counter = counter + 1
}

42
Q

if selection statement

A

if ( grade >= 60 )

Console.WriteLine( “Passed” );

43
Q

if / else double selection statement

A

if ( grade >= 60 )
Console.WriteLine( “Passed” );
else
Console.WriteLine( “Failed” );

44
Q

Conditional Operator

A
  • an be used in place of an if / else statement

- Console.WriteLine( grade>=60 ? “Passed”:”Failed” );

45
Q

Nested if / else Statements

A
if ( grade >= 90 ) 
Console.WriteLine( "A" );
else if ( grade >= 80 ) 
Console.WriteLine( "B" );
else if ( grade >= 70 ) 
Console.WriteLine( "C" );
else if ( grade >= 60 ) 
Console.WriteLine( "D" );
else
Console.WriteLine( "F" );
46
Q

while loop

A

int product = 3;
while ( product <= 100 )
product = 3 * product;

47
Q

Arithmetic compound operators

A

counter = counter + 1

counter += 1

++ counter

counter ++

48
Q

increment operators

A
  • prefix increment ( ++a )

- postfix increment ( a++ )

49
Q

decrement operators

A
  • prefix decrement ( –a )

- postfix decrement ( a– )

50
Q

casting

A

double avg = (double) total / numofgrades

51
Q

for

A

for ( int counter = 1; counter <= 10; ++counter )
Console.Write( “{0} “, counter );

for ( initialization; loopContinuationCondition; increment ) statement

52
Q

while

A

initialization;
while ( loopContinuationCondition ) {
statement
increment; }

53
Q

switch

A
switch ( grade / 10 )
{ 
case 9:
case 10: 
\++aCount;
break;
case 8:
\++bCount;
break;
...
default:
\++fCount;
break;
}
54
Q

continue statement

A

skips the remaining statements in the loop body and proceeds with the next iteration of the loop.

55
Q

Logical Operators

A
  • enable you to form more complex conditions by combining simple conditions
  • The logical operators are && (conditional AND), || (conditional OR), & (boolean logical AND), | (boolean logical inclusive OR), ^ (boolean logical exclusive OR) and ! (logical negation)
56
Q

syntax error

A
  • user typed something in wrong
57
Q

logical error

A
  • compiler will not catch it, but the code will not run correctly
58
Q

run time error

A
  • the user typed something in wrong
59
Q

system

A
  • namespace in the .Net library
60
Q

class

A

a definition of things (blueprint)

61
Q

format specifier

A

{ 0:F } - round to two decimal places

{ 0:C } - formats as currency

62
Q

static

A

the code can run even with no object