CSCI 111 Ch. 1-2 Quiz Flashcards

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
Q

a program called an ? is used to convert assembly language programs into machine code

A

assembler

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

? are English-like and easy to learn and program (e.g. Java, Python)

A

high-level languages

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

a program written in a high-level language is called a ?, which must be translated into ? for execution

A

source code; machine code

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

the translation from source to machine code can be done using an ? or a ?

A

interpreter, compiler

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

an interpreter reads ? from the source code, translates it to the machine code, and then executes it right away

A

one statement

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

a compiler translates ? into a machine-code file, and the machine-code file is then executed

A

the entire source code

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

? 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

A

Java

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

the ? converts the source code to bytecode (JVM - Java Virtual Machine) and then the Java ? converts and executes the byte code line by line

A

compiler; interpreter

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

every Java program must have at least one ?, which has a name that conventionally starts with an ? letter

A

class; uppercase

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

capitalize the first letter of each word in the ? name

A

class

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

in order to run a class, the class must contain a method named ?, which looks like ?. it is where the program begins execution

A

main; public static void main (String [ ] args)

36
Q

a ? represents an action or a sequence of actions

A

statement

37
Q

every statement in Java ends with a ?, which is known as the ? in Java

A

semicolon (;), statement terminator

38
Q

? (also known as keywords) are words that have a specific meaning to the compiler and cannot be used for other purposed in the program

A

reserved words

39
Q

a ? is a group of statements/components surrounded by braces { }

A

block

40
Q

two popular block styles

A

next-line and end-of-line

41
Q

{ }

A

denotes a block to enclose statements

42
Q

( )

A

used with selection statements, loops, and methods

43
Q

[ ]

A

denotes an array

44
Q

//

A

precedes a comment line

45
Q

” “

A

enclosing a string

46
Q

’ ‘

A

enclosing a character

47
Q

;

A

marks the end of a statement

48
Q

proper indenation

A

at least two spaces

49
Q

use a ? to separate segments of the code

A

blank line

50
Q

syntax/compile error

A

detected by the compiler

51
Q

runtime

A

causes the program to abort

52
Q

logic

A

produces incorrect result

53
Q

how to read input from the console

A
  1. create a scanner object Scanner input = new Scanner(System.in);
  2. use the method nextDouble( ) to obtain a double value
54
Q

an identifier is a sequence of characters that consist of ?, ?, ? and ?

A

letters, digits, underscores, and dollar signs

55
Q

an identifier must start with a ?, ?, or ? - it CANNOT start with a ?

A

letter, underscore, or dollar sign; digit

56
Q

an identifier cannot be a ? and cannot be ?, ?, or ?

A

reserved word; true false, or null

57
Q

variables and constants are examples of ?

A

identifiers

58
Q

a ? represents a value stores in the computer’s memory. the value of it is changeable

A

variable

59
Q

ex: declaring a variable

A

int x;
double radius;
char a;

60
Q

ex: assigning values to a variable

A
x = 1;
radius = 1.0;
letter = 'A';
61
Q

ex: declaring and variable AND assigning value in one step

A

int x = 1;
double radius = 1.0;
char a = ‘A’;

62
Q

an ? designates a value for a variable and an ? is known as the assignment operator

A

assignment statement; equal sign =

63
Q

a ? is an identifier that represents a permanent value

A

constant

64
Q

general form of declaring constants

A

final datatype CONSTANTNAME = value;

65
Q

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

A

lowercase; lowercase, capitalize

66
Q

in naming constants, ? all letters and use ? to connect words

A

capitalize; underscores

67
Q

what are the 8 primitive data types? (which are the two we mainly use?)

A
byte
short
int
long
float
double
char
boolean
(we mainly use int and byte)
68
Q

numeric operators

A
\+ addition
- subtraction
* multiplication
/ division
% modulus (remainder)
69
Q

calculations with integers yield a precise integer result (ex: 5/2 yields ? while 5.0/2 yields ?)

A

2; 2.5

70
Q

you can use % to determine if a number is even or odd because an even number % 2 = ? and an odd number % 2 = ?

A

even % 2 = 0

odd % 2 = 1

71
Q

a ? is a value that appears directly in the program (also referred to as ?)

A

literal; hard coding

72
Q

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

A

integer literal

73
Q

an integer literal is assumed to be of the ? type, whose value is between -2^31 and 2^31-1

A

int

74
Q

? literals are written with a decimal point. by default, a floating-point literal is treated as a ? type value

A

floating-point; double

75
Q

the ? type values are more accurate than the float type values

A

double

76
Q

operator precedence

A

( ) first, then *, /, % are applied, and then +, - (if multiple, go L to R)

77
Q

augmented/compound assignment operators

A
\+= addition assignment
-= subtraction assignment
*= multiplication assignment
/= division assignment
%= modulus/remainder assignment
78
Q

increment and decrement operators

A

++var preincrement
var++ postincrement
–var predecrement
var– postdecrement

79
Q

when performing a binary operation involving two operands of different types, Java automatically converts the operand based on these rules:

A
  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
Q

two types of type casting with examples

A

implicit: double d = 3; (type widening)
explicit: int i = (int)3.0; (type narrowing)
int i = (int)3.9; (fraction part is truncated)

81
Q

common errors and pitfalls

A
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
Q

ASCII characters to know: A, a, space, carriage return, tab

A
A: 65
a: 97
space: 32
carriage return: 13
tab: 9
83
Q

ASCII is an ?-bit calculation

A

8-bit

84
Q

Unicode Text Format (UTF) has two bytes per character, but the first ? characters are ASCII

A

128 char

85
Q

what is ASCII?

A

American standard code for information interchange (that crazy chart in your notes)