Test 1 Flashcards

1
Q

How do you output statements?

A

System.out.println(“”);
or
System.out.print(“”);

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

How do you state a variable as a whole number?

A

int x;

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

How do you state a variable as a whole number? plus assign a value?

A

int x = 3;

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

How do you state a variable as a decimal number?

A

double x;

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

How do you state a variable as a decimal number? plus assign a value?

A

double x = 3.05;

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

Import the scanner at the start

A

import java.util.Scanner;

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

Make a Scanner object

A

Scanner input = new Scanner(System.in);

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

Make a Scanner do its stuff (the object is called input) (string is called x)

A

x = input.next();

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

What is the Scanner Input.next””(); if Its a Integer or Double

A

nextInt
nextDouble

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

What is the difference between == & = ?

A

== Is a check for truth and false
= Assigning a value to a variable

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

What is % represent

A

modulo. its the remainder of a division. Wait…… I can make a long division thing!

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

8 % 3 =

A

2

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

9 % 2 =

A

1

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

15284286 % 2 =

A

0 Because its all even…. except the 5…. it still works out

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

x = 4;
y = x++;
z = 5 + x;

((y == 5) && (x == 5) && (z <= 10))
T || F

A

False, y is not equal to 5 but 4
z is 10
x is 5

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

y = x++;
y = ++x;
Difference?

A

yes, (y = x)++ is direct.
The ++ is not between the y = x so first assign the variable then add 1.

(y = ++x) is not direct. The ++ is in between the variables so add 1 then assign.

17
Q

Java reads from

A

right to left

18
Q

x += 2;

A

This is a short version of x = x +2
This is basically adding 2 to the value of x.

19
Q

x/= y;

A
20
Q

Anything wrong with this
code?
int x = 6
int y
x /= 2
x = y
x = 3
y = 3

A

Yeah BIG PROBLEM
No semicolons?

21
Q

What is ‘=!’

A

nothing…. like it doesn’t do anything I think….

22
Q

What is ‘!=’

A

Is not equal to

23
Q

What is ‘!’

A

Not

24
Q

Were do you put the operations + - / * % > <
x = x ‘insert operation’ 2

A

Behind the =
x -= 2

25
Q

what does && represent

A

and

26
Q

what does || represent

A

Or

27
Q

format of a switch statement? string = k
one switch is hi. Add default

A

switch (k)
{
case “hi”:
System.out.println(“hi”);
break;
case “2”:
x = 2;
break;
default:
System.out.println(“erm what the sigma?”);
}

28
Q

while poop

A

while (0 == 0){
System.out.println(“POOOP”);
System.out.println(“POOP”);
System.out.println(“POP”);
}