Basic Java Programming Flashcards
(11 cards)
Name the types of data types in Java.
- Primitive data types used to store simple values
- Refernce data types used to store the address of Objects
What is the fomular for calculating range of values for number data types?
-2^n-1 to 2^n-1 -1
where n is the number of bits for each data type
Name all number data types and the bits for each type.
byte => 8 bits
short => 16 bits
int => 32bits
long => 64bits
Name all the floating point datatypes and the number of bits for each
float => 32 bits
double => 64 bits
How many bits are booleans, and char’s?
boolean => 1 bit
char => 16 bits
Name a few reference datypes?
Classes
Strings
Arrays
Interfaces
What are the type of variables in Java?
- Local variables: variables that exist only within a block or method
- Instance variables: Variables that belong to an object or class and are not static
- Static variables: Variables shared accross all objects
- Parameters: Parameters in Java are variables in a method that receive values when the method is called. They act as inputs for the method to work with.
What are the different types of operators in Java?
- Arithmetic
- Logical
- Relational
name 3 types of loops in Java
for, while, and do while
What is the syntax for creating a forEach loop in java?
String[] names = {“john”, “james”};
for(String name : names){ System.out.println(name); }