Unit 1 - Primitive Types Flashcards
What are block comments?
All text between / and / that will be ignored by the compiler when in a program
What is a class declaration?
Identifies the name, start, and end of class Encapsules all lines of code between { and }
What is the main Method?
Controls all of action in a program
What is System.out?
Object that generates output to the console
System.out.print vs System.out.println
System.out.print displays whatever is in the () on the screen but wait at the end of line for more information to display
System.out.println displays whatever is in the () on the screen, then move cursor to the next line
What is a string literal?
Exact sequence of characters (letters, numbers, or symbols) which are enclosed between two quotation marks
What is a syntax error?
An error that occurs when the syntax in the program was created incorrectly
Program will not compile while these errors are present
Identify the syntax error in each line
System.ot.print (“Hi”);
system.out.print(“Hello);
Line one- out spelled ot
Line two- Uncapitalized system and missing second quotation mark
What is an exception?
Program attempts to divide a number by zero
Occurs while the program is running
Will cause the program to terminate abnormally
What is a logical error?
Programmer accidently uses the wrong symbol for an operation such as using minus instead of plus to find sum of two numbers
Detected when actual output differs from anticipated output
What are primitive data types?
Automatically part of the Java program which does not need to be created by a programmer
What are non-primitive data types?
Methods created by programmer to perform actions that primitive types can’t
Is String a primitive or non-primitive type?
Primitive data type
What is boolean?
Outputs “true” or “false”
Smallest data type at one bit
What is int?
Refers to whole numbers
Medium data type at 32 bits
What is double?
Floating point numbers (w/decimals)
Largest data type at 64 bits
Give an example of int, double boolean, and string.
int - any whole numbers
double - any numbers with a decimal
boolean - true or false
string- any sequence in “”
Give a situation where each data type is most suitable to be used
int - any discrete data points
double - grades, GPA, height, any continuous data
boolean - Scenarios where an occurrence is true or false
string - Scenarios where a name or title, words are used
What is a type?
Set of values (a domain) and a set of operations the set uses
What is a variable?
Name given to a memory location that is holding a value
What is an example of a variable?
firstName
numNotebooks
course