Java Levels 0-2 Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

strings

A

“string”

must have quotation marks

String

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

integers

A

whole #’s w/ no decimal point

weird math

int

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

doubles/floating-point values

A

real numbers

numbers w/ decimal points

double

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

booleans

A

true/false (LOWER CASE)

boolean

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

operators

A

the symbols that we use to perform calculations on diff values

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

arithmetic operators

A

+ - * / %

parenthesis used same as in math

order of operations same

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

concatenation

A

if you “add” anything to a string, it will stick that value on to the string

“Hello” + “werld” = “Hellowerld”

50 + “8” = “508”

“Zoobah” + 0.5 * 3 = “Zoobah1.5”

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

integer division

A

when 2 integers r divided, the result is always an integer

will chop off decimal part NOT round

6/4 = 1

2 / 3 = 0

1 / 5.0 = 0.2 (if ether of the values is a double, will do normal division)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

modulus division

A

only works on integers

gives the remainder of the first number divided by the second number

6 % 4 = 2

12 % 3 = 0

3 % 4 = 3 (if 1st # is less than 2nd #, answer is always 1st number)

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

variables

A

named containers for values

fundamental tool for programming

must be declared

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

variable declarations

A

statements, so must end in semicolons

int blah;

double aVariable;

String porty;

int ting, roo;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

assignments/statements

A

putting a value into a variable for storage

=

blah = 10;

aVariable = 0.6;

porty = “Teapot”;

ting = 10 / 5;

roo = blah / ting; can use other variables in math expression and assignment statements

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

combining declarations & assignments

A

int abc = 12, def = 801;

double xyz = 10.5;

String ijk = “pointy hat”;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

self assignments

A

can use a variable on the right hand side of its own assignment

int fumu = 10;

fumu = fumu + 3;

fumu = fumu - 5;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

type mismatch

A

when variables r assigned values that don’t match their type

int abc = 10.0;

double def = 3; this works tho cuz Java can turn integers into doubles when necessary

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

name conflict

A

w/in a Java program, no 2 variables can be declared w/ the same name, even if they r dif types

int neato;

String neato;

17
Q

import

A

brings in a class from Java’s class library, a large # of classes & methods written by the poeple who made Java, 2 help ppl use Java

18
Q

javax.swing.JOptionPane

A

a collection of useful methods that can pop up diff windows 2 do stuff

19
Q

showInputDialog

A

a method inside of JOptionPane

pops up a window tht lets the user type a string

will then assign the string tht was typed to the variable on the left side of the =

only works for Strings

20
Q

Integer.parseInt

Double.parseDouble

A

takes any String in the parenthesis & tries to turn it itno an integer(or double)

21
Q

condition

A

an expression that compares 2 values & gives a Boolean result(true/false)

5 > 12 (true)

3 > 7 (false)

6 >= 6 (true)

22
Q

conditional operators

A

< less than

> greater than

<= less than/equal to

>= greater than/equal to

== equal to

!= not equal to

don’t work w/ strings

23
Q

.equals()

A

bah.equals(wip) would give true if both bah & wip r the same string

24
Q

if

A

if (a < b) {

System.out.println("blah");

}

if the condition inside the parenthesis is true, then Jaca will do the code inside the curly braces. otherwise, skips it.

25
Q

else

A

if (a < b) {

System.out.println("blah");

} else {

a = a + 10;

}

The code inside the curly braces after the else keyword will be done if the condition turns out to be false

26
Q

else if

A

if (a < b) {

a = a - 5;

} else if (b > c) {

b = b + 9;

}

If 1st condition is false but 2nd is ture, will do 2nd code.

If 1st is true, then will do 1st code & skip else if

27
Q

if-else chains

A

You can put an if, lots of else ifs, and an else together in a “chain” of conditions

can have as many else ifs as u want, but only one if @ beginning and 1 else @ end

Java will work its way down the “chain” & do the code inside the curly braces for the 1st condition which is true

exclusive, so will only actually do the code b/w 1 set of curly braces

28
Q

branching

A

refers to the ability of the program to do diff things under diff conditions

29
Q

Boolean operators

A

&& and

|| or

! not

used only with conditions

30
Q

boolean order of operations

A

AND always before ORs unless parenthesis

math operators ALWAYS take precedence over Boolean operators

(x - 5 < 2) will do x - 5 first