Java is object oriented — models the real world, greater flexibility, modularity, and reusability
2
New cards
What do object oriented languages allow for?
inheritance
3
New cards
what is an object
a specific concrete representation of a class
4
New cards
what is instantiation
the creation of an instance/object from a class; creating a concrete representation of a class (aka initialization)
5
New cards
What are the types of programs in java?
1. Standalones * does not need internet browser * needs a main method 2. Applets * does not need main method * can be executed through a network browser and use a GUI class library
6
New cards
What are the naming conventions for a class?
Every first letter of the word must be capitalized (e.g. HelloWorld)
7
New cards
what is the process of java?
storage, input, process, output
8
New cards
What are the primitive data types?
boolean (1 bit)
char (16 bits)
byte (8 bits)
short (16 bits)
int (32 bits)
long (64 bits)
float (32 bits)
double (64 bits)
9
New cards
what is the function and size of boolean
true or false; 1 bit
10
New cards
what is the size of char?
16 bits
11
New cards
what is the function and size of byte?
integer; 8 bits
12
New cards
what is the function and size of short?
integer; 16 bits
13
New cards
what is the function and size of int?
integer; 32 bits
14
New cards
what is the function and size of long?
integer; 64 bits
15
New cards
what is the function and size of float?
decimal; 32 bits
16
New cards
what is the function and size of double?
decimal; 64 bits
17
New cards
what are the naming conventions for variables?
Capitalize first letter of every word except for the first word (e.g. startingNumber)
18
New cards
what are the naming conventions for methods?
Capitalize first letter of every word except for the first word (same as variables)
19
New cards
what are the naming conventions for constants?
the word “final”(lowercase) followed by the type, followed bu the name of the constant in all caps (e.g. final double PI =3.14)
20
New cards
why are constants important?
* it minimizes memory * makes things more efficient/run faster by optimizing memory * think: video games
21
New cards
what is casting?
casting means explicitly telling Java to make a conversion
22
New cards
when is casting required?
when you want to perform a narrowing conversion
23
New cards
what is important to know about a narrowing conversion?
narrowing runs the risk of losing information
24
New cards
what are the 2 rules for casting of primitive data types?
1. you may cast any non-boolean type to any other non-boolean type 2. you may NOT cast a boolean type to any other type or vice versa
25
New cards
what are the three types of loops common to any programming language?
counted loops, conditional loops, and infinite loops
26
New cards
what are the three types of loops in Java?
for loops, while loops, and do while loops
27
New cards
when should you use a counted loops?
when you know how many times you want something to loop
28
New cards
when should you use conditional loops?
when you don’t know how many times you want something to loop
29
New cards
what is the difference between a while loop and a do while loop?
while loops give the user an option to enter the loop or not (condition occurs at the beginning of the loop), and do while loops force the user to enter the loop at least once (condition occurs at the end of the loop)
“=” is used to assign value, and “==” is a relational operator for comparing
40
New cards
what does x+=y mean?
x=x+y
41
New cards
what does x-=y mean?
x=x-y
42
New cards
what does x\*=y mean?
x=x\*y
43
New cards
what does x/=y mean?
x=x/y
44
New cards
what does y=x++ mean?
y=x+1 (x is incremented after)
45
New cards
what does y=++x mean?
y=x+1 (x is incremented before)
46
New cards
what is selection?
a method used to make choices based on conditions
47
New cards
what is switch case selection used for?
it’s useful for things like menu selection where each choice/outcome is associated with an integer value
48
New cards
what are the limitations of switch case?
* the expression of a switch statement must be int or char (integral type) * it can’t be boolean or any other type * switch case cannot perform relational checks
49
New cards
what are the parts of the software design process?
1. problem definition 2. list of identifiers/analysis 3. algorithm/design 4. coding/implementation 5. testing and debugging 6. maintenance
50
New cards
how many lines can be written in an if statement without brackets?
one line
51
New cards
what is the difference between parsing and casting?
parsing is converting from string (you don’t risk losing any information), and casting is the narrowing or widening of primitive data types in which you risk losing information if you do a narrowing conversion
52
New cards
what is commenting used for?
used to explain your logic and make the program easier to follow/understand
53
New cards
what is a class?
a class is a generic template for a set of objects with similar features