FIRST TEST Flashcards
(27 cards)
what is JAVA?
Object oriented programming
Static keyword
The static keyword denotes that a member variable, or method, can be accessed without requiring an instantiation of the class to which it belongs.
Main method
Is the method where all of the other methods are stored
Whats the syntax to import java classes
import packageName
or
import packageName.ClassName
PG 53
IMPORTANT LOOK AT IT
How do you create a Scanner object
Scanner sc = new Scanner(System.in)
next()
returns the next token stored in the scanner as a string object
nexInt()
returns the next token stored in the scanner as an int value
nextDouble()
returns the next token stored in the scanner as a double value
nextLine()
returns any remaining input on the current line as a string object and advances the scanner to the next line
eight primitive data types
byte 1 short 2 int 4 long 8 float 4 double 8 char 2 boolean 1
casting
converting one data type to another
byte –>short –>int –>long–>float–>double
implicit casting
byte –>double
explicit casting
double –>byte
Integer and double classes
also referred to as wrapper classes
what is a Boolean expression
A boolean expression is anything that you can evaluate and get a result that is boolean, i.e., either true or false. Here are some examples:
&& vs &
&& evaluates second statement if necessary
& always evaluates both expressions
same for OR operators
how to code for loops
for ( initializationExpression; booleanExpression; incrementExpression)
{
statements
}
break statements
Kicks you out of the loop
break;
what is an exception
an exception is an object that contains information about an error that has occurred.
the goal of testing & debugging
testing = find errors
debugging = to fix all errors
syntax error
violate the rules of how java statements must be written
run time error
don’t violate syntax rules, but they throw exceptions that stop the execution of the application
logic error
Logical errors in your code
Example: you should of used + instead of a -