CS Chapter 1 Flashcards
(28 cards)
What is computational thinking?
the thought process needed to build correct, precise, logical programs
When was Java first publicly released? Who was the main developer?
1995; James Gosling
What is a computer program?
specific set of ordered operations for a computer to perform
What is input?
a program gets data from the user (through keyboard, touchscreen, etc.)
What is process in terms of input and output?
A program performs computations on the user input data, such as adding two values like x + y
What is output?
A program puts that data somewhere, such as to a file, screen, network, etc.
Variable
used to store information to be referenced and manipulated in a computer program
Algorithm
a sequence of instructions that solves a problem
Problem solving
creating a methodical solution to a given task
main()
entry point to start the execution of a program; executes program within its curly braces
semicolon
placed at the end of every statement, as English sentences end with a period
What code enables a program to get input?
import java.util.Scanner;
Scanner
Java class used to obtain input from the user in the form of words, number, and phrases
How to use Scanner
Scanner scnr (or any name) = new Scanner(System.in);
x = scnr.nextInt();
string literal
text in “double quotes”
System.out.print(“”) vs System.out.println(“”)
System.out.println() starts a new line after the desired text
newline character
\n; written within string literals to being new lines. Ex. 1\n2\n3\n
Comment
Text a programmer adds to code, to be read by humans to better understand the code but ignored by the compiler
single-line comment
starts with // and includes all the following text on that line; commonly appear after a statement on the same line
multi-line comment
starts with /* and ends with */, where all the text in between is part of the comment; also known as a block comment
Whitespace
refers to blank spaces between items within a statement and blank lines between statements; mostly ignored by compiler
Whitespace Guidelines
- Use blank lines to separate conceptually distinct statements
- Indent lines the same amount
- Align items to reduce visual clutter
- Use a single space before and after any operators to make statements more readable
Compiler
converts high level program into executable program using Java bytecode; scans code line-by-line; recognizes end of statement by semicolon; ignores comments and most whitespace
Syntax error
violate programming rules on how symbols can be combined to create a program; ex. forgetting to use semicolon, uninitialized and undefined variable