Intro to programming UNIT 2 Flashcards
How many characters does ASCII and UNICODE share?
The first 256 Characters
Why do you specify datatypes
It tell the compiler how much memory to set aside for the variable and how to interpret the data in memory
What naming convention do you use for a class
TitleCase. Every word is capitalized and has no spaces
What are the datatypes for whole numbers and how many bits does each use
byte (8 bits)
short (16 bits)
int (32 bits)
long (64 bits)
What is the naming convention for variable names
camelCase. The first word is not capitalized and every word after is capitalized
What makes a valid variable name
Must start with a letter, underscore or a dollar sign
Cannot start with a digit
Not a java reserved keyword
What is the naming convention for constants
Every Letter is capitalized and spaces are underscores
TAX_RATE
How do you declare a constant?
Using the final keyword
What are variable names also known as
Identifier
Reference
Handle
What is the only thing in java that is not an object?
Primitive data types
How many primitive datatypes are there in java
Eight
What are the two non numeric data types? And what are their sizes?
char (16 bits) - will hold a single unicode value
boolean (8 bits) - will hold a true false value
What are the signed floating point data primitives and their sizes
float (32 bits)
double (64 bits)
What is the var datatype?
It’s an inferred datatype. The compiler looks at the data going into the variable and chooses the correct data type for it
When can you use the var datatype?
It can only be used when creating local variables within a method
What is a data literal?
A data literal is data stored within a program
i.e: int ryanAge = 22;
22 would be the data literal
How do you indicate that a data literal is a certain type?
When the var is a long add L to the suffix
i.e: long ryanAge = 10000000000000L;
Suffix a long by an L for it to be considered a long instead of an int
What happens when you divide two integers?
Java will truncate the result.
ie: 5 / 2 = 2.
it will simply remove the decimal point. IT WILL NOT ROUND OFF NUMBERS
What do you call a variable?
An identifier
What does ‘m’ represent
It represents a char literal
How do you get 1 char from the Scanner?
input.next().charAt(0);
When the compiler assumes the conversion what is this called
An implicit conversion
What is an operator
An operator is a symbol that performs built-in calculations
How do you import the random function
import java.util.Random;