CSCI 111 Ch. 1-2 Quiz Flashcards

(85 cards)

1
Q

a number system consists of (2 things)

A
  1. set of valid characters

2. place values

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

the base-10 number system is also known as

A

decimal

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

what are the valid characters in the base-10/decimal number system?

A

0-9

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

in the base-10/decimal number system, place values increase by orders of

A

10 (10^0, 10^1, 10^2 and so on in the left direction)

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

Why do we use base 2 (binary) instead of base 10 (decimal)? What does this mean?

A

Electrostatic Discharge (if electronics are exposed to ESD, voltage can spike -> in base 10, 1v to 8v is a jump of 8000)

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

the base-2 number system is also known as

A

binary

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

what are the valid characters in the binary number system?

A

0 and 1

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

in the base-2/binary number system, place values increase by orders of

A

2 (2^0, 2^1, 2^2 and so on in the left direction)

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

what is 1 byte equal to (in terms of bits)?

A

8 bits

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

what is 1 word equal to (in terms of bytes)?

A

2 bytes

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

what are the steps for converting from decimal to binary?

A
  1. identify the largest place value that is less than or equal to your number
  2. set the bit to 1 for that place value
  3. subtract the place value from your number
  4. repeat steps 1-3 until the number is zero
  5. set the remaining bits to zero
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

the base-16 number system is also known as

A

hexadecimal

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

what are the valid characters in the hexadecimal number system?

A

0-9, A-F

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

in the base-16/hexadecimal number system, place values increase by orders of

A

16 (16^0, 16^1, 16^2 and so on in the left direction)

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

in converting hexadecimal to binary, we have to look at it in terms of ? bits because 16 = 2^4

A

4

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

what are the place values for the binary > hexadecimal conversion chart?

A

8 4 2 1

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

Java is an ? and ? language that uses an ? / text editor such as Notepad ++

A

object oriented (OO), compiled, Integrated Development Environment (IDE)

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

what is the basic skeleton of a java code?

A

class name & main method

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

to invoke the java compiler, ? which creates MyProgram.class

A

javac MyProgram.java

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

to execute the program, ?

A

java MyProgram

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

what are computer programs (aka software)?

A

instructions to the computer/how we tell the computer what to do

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

programs are written using ?

A

programming languages (e.g. Java)

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

? is a set of primitive instructions built into every computer. it is in the form of ?

A

machine language; binary code

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

? were developed to make programming easy

A

assembly languages

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
a program called an ? is used to convert assembly language programs into machine code
assembler
26
? are English-like and easy to learn and program (e.g. Java, Python)
high-level languages
27
a program written in a high-level language is called a ?, which must be translated into ? for execution
source code; machine code
28
the translation from source to machine code can be done using an ? or a ?
interpreter, compiler
29
an interpreter reads ? from the source code, translates it to the machine code, and then executes it right away
one statement
30
a compiler translates ? into a machine-code file, and the machine-code file is then executed
the entire source code
31
? is a powerful and versatile programming language that enables users to develop and deploy applications on the Internet for servers, desktop computers, and mobile devices
Java
32
the ? converts the source code to bytecode (JVM - Java Virtual Machine) and then the Java ? converts and executes the byte code line by line
compiler; interpreter
33
every Java program must have at least one ?, which has a name that conventionally starts with an ? letter
class; uppercase
34
capitalize the first letter of each word in the ? name
class
35
in order to run a class, the class must contain a method named ?, which looks like ?. it is where the program begins execution
main; public static void main (String [ ] args)
36
a ? represents an action or a sequence of actions
statement
37
every statement in Java ends with a ?, which is known as the ? in Java
semicolon (;), statement terminator
38
? (also known as keywords) are words that have a specific meaning to the compiler and cannot be used for other purposed in the program
reserved words
39
a ? is a group of statements/components surrounded by braces { }
block
40
two popular block styles
next-line and end-of-line
41
{ }
denotes a block to enclose statements
42
( )
used with selection statements, loops, and methods
43
[ ]
denotes an array
44
//
precedes a comment line
45
" "
enclosing a string
46
' '
enclosing a character
47
;
marks the end of a statement
48
proper indenation
at least two spaces
49
use a ? to separate segments of the code
blank line
50
syntax/compile error
detected by the compiler
51
runtime
causes the program to abort
52
logic
produces incorrect result
53
how to read input from the console
1. create a scanner object Scanner input = new Scanner(System.in); 2. use the method nextDouble( ) to obtain a double value
54
an identifier is a sequence of characters that consist of ?, ?, ? and ?
letters, digits, underscores, and dollar signs
55
an identifier must start with a ?, ?, or ? - it CANNOT start with a ?
letter, underscore, or dollar sign; digit
56
an identifier cannot be a ? and cannot be ?, ?, or ?
reserved word; true false, or null
57
variables and constants are examples of ?
identifiers
58
a ? represents a value stores in the computer's memory. the value of it is changeable
variable
59
ex: declaring a variable
int x; double radius; char a;
60
ex: assigning values to a variable
``` x = 1; radius = 1.0; letter = 'A'; ```
61
ex: declaring and variable AND assigning value in one step
int x = 1; double radius = 1.0; char a = 'A';
62
an ? designates a value for a variable and an ? is known as the assignment operator
assignment statement; equal sign =
63
a ? is an identifier that represents a permanent value
constant
64
general form of declaring constants
final datatype CONSTANTNAME = value;
65
in variable and method names, use ?. if the name consists of several words, concatenate all in one, using ? for the first word and ? the first letter of each subsequent word in the name
lowercase; lowercase, capitalize
66
in naming constants, ? all letters and use ? to connect words
capitalize; underscores
67
what are the 8 primitive data types? (which are the two we mainly use?)
``` byte short int long float double char boolean (we mainly use int and byte) ```
68
numeric operators
``` + addition - subtraction * multiplication / division % modulus (remainder) ```
69
calculations with integers yield a precise integer result (ex: 5/2 yields ? while 5.0/2 yields ?)
2; 2.5
70
you can use % to determine if a number is even or odd because an even number % 2 = ? and an odd number % 2 = ?
even % 2 = 0 | odd % 2 = 1
71
a ? is a value that appears directly in the program (also referred to as ?)
literal; hard coding
72
an ? can be assigned to an integer variable as long as it can fit into the variable. a compilation error would occur if the literal were to large for the variable to hold
integer literal
73
an integer literal is assumed to be of the ? type, whose value is between -2^31 and 2^31-1
int
74
? literals are written with a decimal point. by default, a floating-point literal is treated as a ? type value
floating-point; double
75
the ? type values are more accurate than the float type values
double
76
operator precedence
( ) first, then *, /, % are applied, and then +, - (if multiple, go L to R)
77
augmented/compound assignment operators
``` += addition assignment -= subtraction assignment *= multiplication assignment /= division assignment %= modulus/remainder assignment ```
78
increment and decrement operators
++var preincrement var++ postincrement --var predecrement var-- postdecrement
79
when performing a binary operation involving two operands of different types, Java automatically converts the operand based on these rules:
1. if one of the operands is double, the other is converted into double 2. if one of the operands is float, the other is converted into float 3. if one of the operands is long, the other is converted into long 4. otherwise, both operands are converted into int
80
two types of type casting with examples
implicit: double d = 3; (type widening) explicit: int i = (int)3.0; (type narrowing) int i = (int)3.9; (fraction part is truncated)
81
common errors and pitfalls
``` error 1. undeclared/uninitialized variables and unused variables error 2. integer overflow error 3. round-off errors error 4. unintended integer division pitfall 1. redundant input objects ```
82
ASCII characters to know: A, a, space, carriage return, tab
``` A: 65 a: 97 space: 32 carriage return: 13 tab: 9 ```
83
ASCII is an ?-bit calculation
8-bit
84
Unicode Text Format (UTF) has two bytes per character, but the first ? characters are ASCII
128 char
85
what is ASCII?
American standard code for information interchange (that crazy chart in your notes)