Chapter 2 : Data Processing Flashcards

1
Q

Describe TextBox control ( 5 )

A
  1. Rectangular area
  2. Can accept keyboard input from the user
  3. Locates in the common control group of the toolbox
  4. Default name is textBoxn( n = 1 , 2 , 3 … )
  5. Double click to add it to the form
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What property does TextBox controls?

A
  1. Text property which stores user inputs
  • Only accepts string values
    textBox1.Text = “Hello”;

Clear TextBox control content
textBox1.Text=””

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

How to declare variable in C#?

A
  1. DataType VariableName;

String text
double currency_rate

  • Variable is a storage location in memory
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What are the bytes used in int, float and double?

A
  1. int - 4 bytes
  2. float - 4 bytes
  3. double - 8 bytes
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is char used for?

A
  1. Storing a single character
  • String is a collection of character
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is most data type known as?

A
  1. Primitive data types
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

Ways to use variables ( 3 )

A
  1. Store value
    product = “Mac Book”
  2. Assign to another value
    productLabel.Text = product
  3. Display in a message box
    MessageBox/.Show(product)
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What does a local variable belongs to?

A
  1. Method which it was declared
  • Only statements inside that method can access the variable
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is the lifetime of a variable?

A
  1. Time period during which the variable exists in memory while the program is executing
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

List out the rules of variables ( 4 )

A
  1. Can assign a value only if the value is compatible with the variable’s data type
  2. A variable holds one value at a time
  3. Variable must be assigned before it can be used, I can initialize the variable with a value when declare it
  4. Multiple variables with the same type may be declared with one statement
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

Can the value of int and double surrounded by quotes?

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

What does the decimal data type indicates?

A
  1. 128 bit data type
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What is the advantages of decimal compared to double

A
  1. Makes appropriate for financial and monetary calculation since it has more precision and smaller range
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

How to declare decimal data type?

A
  1. decimal payRate = 28.5m
  2. decimal price = 8.95M
  • Need to add the letter M ( or m ) to a decimal value
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

How to type casting?

A
  1. Use a cast operator with parentheses with the type keyword
    ( type )

wholeNumber = ( int ) moneynumber

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

List out arithmetic calculation ( 5 )

A
    • , Add 2 numbers
    • , Subtracts one number from another
    • , Multiplies one number by another
  1. / , Divides one number by another and gives the quotient
  2. % , Divides one number by another and gives the remainder
17
Q

List out the result of mixed data type ( 3 )

A
  1. When an operation involves an int and a double, int is treated as double and the result is double
  2. When an operation involves an int and a decimal, it is treated as decimal and the result is decimal
  3. An operation involving a double and decimal isn’t allowed
18
Q

What are the types of input collected from the keyboard?

A
  1. Combinations of characters
    ( String Literals )
19
Q

How to let string literals input from keyboard to convert string into numeric data types?

A
  1. int.Parse
  2. double.Parse
  3. decimal.Parse
20
Q

How to show numeric values in lablel?

A
  1. Using ToString method
21
Q

List out format strings for the ToString method

A

1.”N” or “n”
- Number Format
- 12.3 ToString (“n3”) = 12.300
2. “F” or “f”
- Fixed-point Scientific Format
- 123456.0 ToString(“f2”) = 123456.00
3. “E” or “e”
- Exponential Scientific Format
- 123456.0 ToString(“e3”) = 1.235e + 005
4. “C” or “c”
- Currency Format
- -1234567.8 ToString(“C”) = ( $1,234,567.80 )
5. “P” or “p”
- Percentage Format
- .234 ToString(“P”) = 23.40%

22
Q

What is an exception?

A
  1. An exception is an unexpected error that happens while a program is running
23
Q

What will happen if an exception isn’t handled by the program?

A
  1. The program will abruptly halt
24
Q

List out the codes for exception handling

A

try{
}
catch {
}

  • The catch block will execute when there is exception in the try block
25
Q

What is the constant value?

A
  1. A constant is a name that represents a value that cannot be changed during the program’s execution
26
Q

How to declare constant variable in C#?

A
  1. const double interest_rate = 0.129
27
Q

What is a field? ( 2 )

A
  1. A variable that is declared at the class level
  2. It is declared inside the class, not inside the method
28
Q

What is the scope of the field variable?

A
  1. Entire class

public partial class Form1 : Form
{
// Declare a private field to hold a name.
private string name = “Charles”;
public Form1()
{
InitializeComponent();
}
private void showNameButton_Click(object sender, EventArgs e)
{
MessageBox.Show(name);
}
private void chrisButton_Click(object sender, EventArgs e)
{
name = “Chris”;
}

29
Q

List out 2 predefind constants and 2 complex mathematical calculations

A
  1. Mathematical Calculations
    • Math.Sqrt(x)
    • Math.Pow( x , y )
  2. Predefined Constants
    • Math.PI
    • Math.E
30
Q

How to create keyboard access key to buttons

A
  1. Create a button ( Exit )
  2. Add & before a letter ( E&xit )
  3. Go to the Form ( Set Quit to the button )
  4. User press Alt + E ( Quit the program )
31
Q

List out 2 properties to set up Colors

A
  1. BackColor ( Background Color )
  2. ForeColor ( Foreground Color )
32
Q

List out the 3 tabs for choosing color

A
  1. Custom
    • Color palette
  2. Web
    • Colors displayed consistently with Web Browser
  3. System
    • List color defined in current Windows
33
Q

How to add background image to a form?

A
  1. Use the BackgroundImage property in a Form
34
Q

List out property values for BackgroundImageLayour property

A
  1. None
  2. Title ( Repeat the image until it convers the screen width and height )
  3. Center
  4. Stretch
  5. Zoom
35
Q

What is a GroupBox & Container?

A
  1. \GroupBox is a container with a thin border and an optional title that can hold other controls
  2. Container is a container that can hold other controls
36
Q

What is the difference between Panel & GroupBox

A
  1. A panel cannot display a title and text while GroupBox can
  2. A panel border can be specified byt its BorderStyle property