Java Unit 1 Flashcards
(40 cards)
These rules specify the basic vocabulary of the language and how programs can be constructed using things like loops, branches, and subroutines.
Syntax
A set of rules that determine the meaning of a program written in a language.
Semantics
Java programs are compiled into what?
Byte code!
What is a subroutine call statement?
A subroutine call statement is a predefined set of routines for a subroutine to complete.
Example: System.out.println is a subroutine.
In order to define a program, a class must include a subroutine named?
main
public static void main(String[] args) {
statements
}
Why do you have to type “public” in the first line of main()?
Using “public” means that the routine can be called from outside of the program.
A subroutine can’t exist by itself. What does it HAVE to be a part of?
A class
What is a package?
A group of classes.
To execute a program, you only need the compiled “ “ file, not the source code.
class
When defining a variable, capitalizing every word except the first is referred to as what?
Camel case
These names consist of several simple names separated by periods.
Compound names, also called qualified names.
Example: System.out.println
An “ “ represents anything that refers to or computes a data value.
expression
Name all of the primitive types. Hint: there are 8
- byte - 16 bits
- short
- int - 32 bits
- long - 64 bits
- float
- double
- char
- boolean
What kind of numbers do float and double types hold?
real numbers
What range of values can a byte type hold?
Anywhere from -128 to 127 which equals up to 256 integers.
What range of values can a short type hold?
From -32,768 to 32,767 (16 bits)
How many bytes of memory are float data types represented by?
Four bytes (chomp, chomp, chomp, chomp)
How many bytes of memory does the char type occupy?
Two bytes (chomp, chomp)
A char character is stored as a “” bit integer code number.
16
A data value is stored in the computer as a sequence of what?
bits
In a program, you represent constant values as “”.
literals (I literally did not know that)
What is the escape character for a carriage return?
‘\r’
What is the escape character for a linefeed?
‘\n’
How can you express a number in an exponential form?
By using ‘e’
Example: ‘y = 1.3e12’
This means that 1.3 will be raised to the power of 12.