Programming Fundamentals: Exam 1 Review

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

byte range

-128 to 127

When was the first public release of Java?

1995

float

32 bit decimal values, give better precision but sometimes lower accuracy. Don't compare floating point numbers to zero or precise values (so never use ==). Instead use Math.abs(variable1 - variable2) < 0.0001 or something similar as a buffer

Bits

binary digits, either 1 or 0

Debugging strategies

exceptions, assertions, error stream, breakpoints, and log files

random()

gets random (0:1). x = 5 * random(); yields something like 3.65

pow(double, double)

power / exponent. x = Math.pow(3.0, 2.0); yields 9.0

Application/App/program

programmer-created sequence of instructions

Sub areas with CSE

-Software Development (programming) -Software engineering (process) -computational theory (math, potential, limits) -problem solving

Computer

-input/output devices (a.k.a peripherals), like a screen and keyboard -Storage, like a disk (harddrive) -memory, or RAM -processor (the OS) -clock

bitwise operators

For integral operand types, such as int, the single character versions represent different operators known as bitwise operators. When both operands are integers, the bitwise operators evaluate to an integer value. For boolean operands, the bitwise operators evaluate to the same boolean value as the logical operators, but do not perform short circuit evaluation, which is discussed elsewhere. Mixing integral and boolean operands in a bitwise operator, such as 2 & false, generates a syntax error.

static

means that a method is accessible and usable even though no objects of the class exist., and that this number is shared by all objects of type specified in the public class. also means that only a class can call for this to execute. Also means only one copy exists and you can access it without declaring a Math object

final

means that this value can't be changed

Syntax error

misuse of language rules, a misspelled programming language word

private

only usable inside the parent class

increment/decrement

operators that are formatted as variable++; and variable--; respectively, which add or subtract one from the value of the variable

Associativity

order in which operands are used with operators

Source code

programming statements written in high-level programming language

Compound arithmetic operators

provide shorthand way to update a variable (+=, *=, -=, etc.). Ex: variable1 += variable2 is the same as variable 1 = variable1 + variable2

Cache

relatively small, volatile storage with fastest access located on processor chip

Variable

represents a memory location used to store data; "int <variable> = <value>; declares a new variable

round(double)

rounds

floor(double)

rounds down. x = floor(867.5309); yields 867

ceil(double)

rounds up

Computer science and computer engineering are similar

science tells us how systems work together and engineering is how we build them

Java's advantages

security features and being "neutral" (can run on a lot of different hardware)

Assignment

setting value of variable

Programming statements

similar to English sentences; commands that carry out program tasks

argument

similar to a parameter; an input value to a method that appears between parentheses (i.e. the areaSquare in "double areaSquare = 49.0;")

Short circuit evaluation

skips evaluating later operands if the result of the logical operator can already be determined (operand1 && operand2, operand1 || operand2, etc.)

Constant values

sometimes we have values that never need to change. These constants can be specified by final <variable> = <value>; once declared, constants cannot be changed

Bytecode

statements saved in a file, a binary program into which the Java Compiler converts source code

assignment statement

stores the right-side item's current values to the left-side variable (i.e. variable Name = expression;)

sqrt(double)

takes the square root. x = Math.sqrt(2.25); yields 1.5

Assignment operator

the equal sign =, the value to the right is assigned to the variable on the left

Access specifier

the keywords public, private, default, and protected which determine how an identifier can be used (i.e. like public class ExampleClass { }, or private int x = 10;)

Machine Language

the most basic, circuit-level, low-level programming language, is in 0s and 1s

Code

the textual representation of a program

Good practice for switch statements

to always have a default case for a switch statement, and not forgetting a break statement at the end of a case

Pseudo-random

to create some random numbers with a pattern, use Random randGen = new Random(<number>);

Processors

to support different calculations, circuits called _____ were created to execute instructions/programs using data

Compiler/Interpreter

translates language statements (source code) into machine code

Boolean type

true or false, i.e. boolean variable = false; and then later boolean variable = true;

reference type

variables that hold a reference to the object, i.e. String

primitive

variables that hold their own values

Nested if-else statements

when one if statement follows another, the first else clause encountered is paired with the most recent if encountered. No matter how many levels of if...else statements are needed to produce a solution, the else statements are always associated with their ifs on a "first in-last out" basis

operator

a symbol for a built-in language calculation (i.e. arithmetic operators)

Scanner

a text parser that can read numbers, words, or phrases from the user. Create a scanner object via "Scanner scnr = new Scanner(System.in);" and then have variables equate input by "<variable> = scnr.nextInt();" or scnr.nextLine();

if-else

a two way selection structure; If you want to take an action when a Boolean expression is true but take a different action when the expression is false, you use an if...else statement. Ex. "if (x == 0) System.out.println(expr1); else System.out.println(expr2);"

Selection

a type of branching where the program selects on course of action

Volatile storage

a type of computer memory that needs power to preserve stored data

Data type

a type of data that can be stored, i.e. how much memory an item occupies and what types of operations can be performed on data

Debugging

aka Troubleshooting, a term coined by Grace Hopper, is the process of determining and fixing the cause of a problem in a computer program. A common predicted-problem testing approach is to insert print statements

High Level programming language

allows you to use a vocabulary of reasonable terms (is human readable)

Logic errors

also known as semantic errors; incorrect order or procedure, the program may run because the syntax is correct but it will provide inaccurate output. is a type of run-time error

Initialization

an assignment made when declaring a variable (i.e. int Variable = 0; or double Variable = 0.0);

Object

an instance of a class (if the class is the blueprint, the object is the building)

Arithmetic operators

an operator is a symbol for built-in language calculation like + for addition. Precedence for arithmetic operators is (), negative, *, /, %, +, -

API

application programming interface, aka Java class library. Contains infomration about how to use every prewritten Java class (similar to man pages). Java's class' documentation found here http://docs.oracle.com/javase/8/docs/api/

Strings

are objects that hold a series of characters; sequences of characters in memory. Each string character has a position number called an index. It is a reference type (variables hold a reference to the object). **In Java, String is a class and each created string is an object

Char

are unsigned ints that represent characters

long

can hold the values between -2^63 to one less than 2^63

integer

can hold values from -2^31 to 1 less than 2^31

Instance methods

can only be invoked by an instance of the class

variable types (primitive)

char, int, float, double, boolean, byte, short, long. The integer types are byte (8 bit, -128 to 127), short (16 bit, -32768 to 32767), int (32 bit, -2 billion to 2 billion), and long (64 bit, -9 quintillion to 9 quintillion). The floating point types are floats (32 bit) and double (64 bit). The character type represents a single character (char, 16 bit)

Java Interpreter

checks bytecode and communicates with the OS, executes bytecode instructions line by line within the JVM

conditional expression (or ternary expressions)

condition ? exprWhenTrue : exprWhenFalse

C

created by Kemighan and Ritchie at AT&T Bell labs in 1978, became the dominant programming language in the 80s/90s

Class

defines the attributes (fields/variables) and capabilities (methods) of a real world object (i.e. public class, private class, etc.). a class is like a blueprint from which individual objects are created

Java

developed by Sun Microsystems, is an object-oriented language, is general-purpose, does not execute instructions on the computer directly but on a JVM (Java Virtual Machine)

branching

directs a program to execute either one statement group or another, depending on the expression's value

public

everyone can see it / use it throughout the code

Multi-branch if-else arrangment

if (expr1) { } else if (expr2) { }

how to convert a String to a primitive type

int numberString = Integer.parseInt(stringNumber);

Software engineering

involves development/programming, software support, social interaction, design, iteration, release, maintenance, and lasts the software's lifetime

Character specific methods

isDigit(char), isLetter(char), isWhitespace(char), toUppercase(char), and toLowercase(char)

void

means it doesn't return a value when it finishes executing. But this doesn't mean that main () method is empty or it won't produce output

Running a Java Application and correcting logic errors

After a program compiles with no syntax errors, you can execute it. However, just because a program compiles and executes, that does not mean the program is error free.

C++

C-based language, involves object-oriented programming, designed by Strastrup in 1985

IDE

Integrated development environment, like Eclipse or IntelliJ; a software application that provides tools to computer programmers for software development. An IDE normally has a source code editor, build automation tools and a debugger

Java math library

Java comes with math functions in java.lang.Math.

Debuggers

Most IDEs are integrated with a debugger which provides tools for debugging: breakpoints, step-through, stack trace, and variable watch. In most cases you must run in the debug configuration (debug mode) to enable to debugger

Javascript

NOT Java, but a scripting language like Python, Ruby, PHP, etc.

Cooking metaphor

Processor = chef, program = recipe, data = ingredients, memory = shelf

Operands

The data that operators work with. Ex: unitSold = 12 Then unitSold and 12 are operands.

switch statement

The switch statement uses up to four keywords to test a single variable against a series of exact integer or character values. The keywords are switch, case, break, and default. It is useful when you need to test a single variable against a series of exact integer (including int, byte, and short types), character, or string values.

|| and short circuit evaluation

The || operator also uses short-circuit evaluation. In other words, because only one of the Boolean expressions in an || expression must be true to cause the dependent statements to execute, if the expression to the left of the || is true, then there is no need to evaluate the expression to the right of the ||

identifier

a name created by a programmer for an item like a variable or method. must be a sequence of letters and must start with a letter. Can only contain letters, digits, underscores, or dollar signs. Cannot have spaces, start with a number, be a Java reserved keyword, or be true, false, or null

floating-point literal

a number with a fractional part, even if that fraction is 0 (i.e. it has a decimal point)

Development environment

a set of tools used to write programs

Computer program

a set of written instructions that tell the computer what to do

Syntax

a specific set of rules for the language (what symbols you'll use)

==

When determining equivalency in Java, you use a double equal sign

Objects and relational operators

You can use the equals and not equals comparisons (== and !=) with objects, but when you use them, you compare the objects' memory addresses instead of their values.

Relational/equality operator

a < b, a >= b, a == b, a != b, etc.

Memory

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

expression

a combination of items, like variables, literals, and operators, that evaluates to a value

method

a list of statements that can be executed by referring to the method's name

Return statements

a method can only return one item, and return statements may appear as any statement in a method, not just as the last statement. Also, multiple return statements may exist in a method. If the method definition indicates a certain return type, such as int, then the return must supply an integer

Assertion

a statement that tests a condition we expect to be true. formatted as such: assert variable > 0 : "Error!"); (note that the error message will appear in red in the error stream)


Set pelajaran terkait

Chapter 7: PART 2 records retrieval and transfer

View Set