Computer science

Ace your homework & exams now with Quizwiz!

Modulo operator

(%) evaluates the remainder of the division of two integer operands. Ex: 23 % 10 is 3.

Bits

0s and 1s are known as bits (binary digits).

equality operaton

== evaluates to true if the left side and right side are equal.

If branch

A branch taken only if an expression is true.

nested if-else

A branch's statements can include any valid statements, including another if-else statement, which are known as nested if-else statements.

Warning

A compiler will sometimes report a warning, which doesn't stop the compiler from creating an executable program, but indicates a possible logic error.

Program

A computer program consists of instructions executing one at a time.

Final variable

A constant variable is also known as a final variable.

Scientific notation

A floating-point literal using scientific notation is written using an e preceding the power-of-10 exponent, as in 6.02e23 to represent 6.02 x 1023.

Literal

A literal is a specific value in code like 2.

Bug

A logic error is an error that occurs while a program runs.

Method call

A method is a list of statements executed by invoking the method's name, such invoking known as a method call.

Block comment

A multi-line comment

Identifier

A name created by a programmer for an item like a variable or method is called an identifier.

Newline character

A new output line can also be produced by inserting \n, known as a newline character, within a string literal.

Input

A program gets data, perhaps from a file, keyboard, touchscreen, network, etc.

Process

A program performs computations on that data, such as adding two values like x + y.

Output

A program puts that data somewhere, such as to a file, screen, network, etc.

Program

A program starts in main(), executing the statements within main's braces { }, one at a time.

Keyword

A reserved word

Screen

A screen (or monitor) displays items to a user.

Algorithm

A sequence of instructions that solves a problem is called an algorithm.

Executable program

A sequence of machine instructions together form an executable program.

Math class

A standard Math class has about 30 math operations, known as methods.

Escape sequence

A two-character sequence starting with \ that represents a special character.

Double

A variable declared as type double stores a floating-point number.

Char

A variable of char type, as in char myChar;, can store a single character like the letter m.

Evaluates

An expression evaluates to a value, which replaces the expression. Ex: If x is 5, then x + 1 evaluates to 6, and y = x + 1 assigns y with 6.

Expression

An expression is a combination of items, like variables, literals, operators, and parentheses, that evaluates to a value, like 2 * (x + 1).

Precedence rules

An expression is evaluated using the order of standard mathematics, such order known in programming as precedence rules.

Constant variable

An initialized variable whose value cannot change is called a constant variable.

Arguments

Any method input values, or arguments, appear within ( ), separated by commas if more than one.

Compile-time error

Because a syntax error is detected by the compiler, a syntax error is known as a type of compile-time error.

Infinity

Dividing a nonzero floating-point number by zero results in infinity or -infinity, depending on the signs of the operands.

Semicolon

Each statement typically appears alone on a line, and ends with a semicolon, like English sentences end with a period.

Fixing the first error

Focus on FIRST error message, ignoring the rest. Look at reported line of first error message. If error found, fix. Else, look at previous few lines. Compile, repeat.

Seed

For the first call to nextInt(), no previous random integer exists, so the function uses an integer known as the seed.

Variables

Programs use variables to refer to data, like x.

Newline

System.out.println (note the ln at the end, short for "line"), starts a new output line after the outputted values, called a newline.

String literal

Text in double quotes " " is known as a string literal.

Implicit conversion

The compiler automatically performs several common conversions between int and double types, such automatic conversion known as implicit conversion.

Precedence rules

The order in which operators are evaluated in an expression are known as precedence rules.

Processors

To support different calculations, circuits called processors were created to process (aka execute) a list of desired calculations.

Compilers

To support high-level languages, programmers created compilers, which are programs that automatically translate high-level language programs into executable programs.

Whitespace character

a character used to represent horizontal and vertical spaces in text, and includes spaces, tabs, and newline characters.

Memory

a circuit that can store 0s and 1s in each of a series of thousands of addressed locations.

Type conversion

a conversion of one data type to another, such as an int to a double.

Method

a list of statements executed by invoking the method's name, such invoking known as a method call.

Floating-point literal

a number with a fractional part, even if that fraction is 0, as in 1.0, 0.0, or 99.573.

Floating-point number

a real number, like 98.6, 0.0001, or -666.667.

String

a sequence of characters.

Reserved word

a word that is part of the language, like int, short, or double.

Lower camel case

abuts multiple words, capitalizing each word except the first, as in numApples or peopleOnBus.

Keyboard

allows a user to provide input to the computer.

Logic error

also called a bug, is an error that occurs while a program runs.

ASCII

an early standard for encoding characters as numbers.

Assignment statement

assigns a variable with a value, such as x = 5.

Assignment statement

assigns the variable on the left-side of the = with the current value of the right-side expression.

Whitespace

blank spaces (space and tab characters) between items within a statement, and to blank lines between statements (called newlines).

Relational operaton

checks how one operand's value relates to another, like being greater than.

Object

consists of some internal data items plus operations that can be performed on that data.

System.out.print

constructs supports output.

Computational thinking

creating a sequence of instructions to solve a problem

If

executes a group of statements if an expression is true.

If-else

executes one group of statements when an expression is true, and another group of statements when the expression is false.

Type cast

explicitly converts a value of one type to another type.

Braces

{ }, sometimes redundantly called curly braces, represent a grouping, such as a grouping of statements.

Case sensitive

Identifiers are case sensitive, meaning upper and lower case letters differ.

Variable

In a program, a variable is a named item, such as x or numPeople, used to hold a value.

Incrementing

Increasing a variable's value by 1, as in x = x + 1, is common, and known as incrementing the variable.

Machine instructions

Instructions represented as 0s and 1s

Unary minus

Minus (-) used as negative is known as unary minus.

Not a number

Not a number (NaN) indicates an unrepresentable or undefined value.

Scnr.nextLine()

gets all remaining text on the current input line, up to the next newline character (which is removed from input but not put in stringVar).

Branch

is a program path taken only if an expression's value is true

Variable declaration

is a statement that declares a new variable, specifying the variable's name and type.

Operator

is a symbol that performs a built-in calculation, like +, which performs addition.

Boolean

is a type that has just two values: true or false.

Character literal

is surrounded with single quotes, as in myChar = 'm';.

Comment

is text a programmer adds to code, to be read by humans to better understand the code, but ignored by the compiler.

what happens to the remainder when integars are divided?

it gets thrown away

Expression

may be a number like 80, a variable name like numApples, or a simple calculation like numApples + 1.

Assuming scnr already exists, which statement gets an input number into variable numCars?

numCars = scnr.nextInt ( ) ;

Type a statement that gets an input value into variable numUsers. Assume scnr already exists.

numUsers = scnr.nextInt ( ) ;

Overflow

occurs when the value being assigned to a variable is greater than the maximum value the variable can store.

print or println statements

output various values

Compound operators

provide a shorthand way to update a variable, such as userAge += 1 being shorthand for userAge = userAge + 1. Other compound operators include -=, *=, /=, and %=.

Random

provides methods that return a random integer in the range −231 to 231−1 or a programmer-defined range.

Multi-line comment

starts with /* and ends with */, where all text between /* and */ is part of the comment.

Single-line comment

starts with // and includes all the following text on that line.

If-else

structure has two branches: The first branch is taken if an expression is true, else the other branch is taken.

String literal

surrounds a character sequence with double quotes, as in "Hello", "52 Main St.", or "42".

Scanner

text parser that can get numbers, words, or phrases from an input source such as the keyboard.

Syntax error

to violate a programming language's rules on how symbols can be combined to create a program.

Logical operator

treats operands as being true or false, and evaluates to true or false. Logical operators include AND, OR, and NOT.

Logical OR (||)

true when at least one of its two operands are true .

Logical AND (&&)

true when both of its operands are true .

Logical NOT (!)

true when its one operand is false, and vice-versa.


Related study sets

Chapter 35 Comfort and Pain Management

View Set

Property Present and Future Interests

View Set

Foundations & Practice of Mental Health Nursing

View Set

Exam 1 - Chapter 30 Diabetes Mellitus

View Set

VDV: Applications and Installation (Part 3 of 3)

View Set

Retirement plans - life insurance exam

View Set