Test 2 Flashcards

1
Q

We gota do some recap… If you know this then just 5 star it

A

yeah and 5 star this too

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

Import a scanner into the class.

A

import java.util.Scanner;

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
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
4
Q

User input for a int variable

A

int x = input.nextInt();

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

Make a While loop with a condition it a int x is not int y

A

while (x != y){
//Code here
}

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

what is a condition?

A

Its kinda like a true or false statement.
It turns a set of instructions into a true or false.

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

What happens if a condition is true? What happens if it’s false?

A

In terms of a while loop “True = run”, “False = don’t run just skip”

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

What does it mean to break out of a loop?

A

It means the condition is false and it does not run the loop again.

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

What is a for loop?
What are the parameters for?

A

A specific loop that acts with parameters (not the ones from before, I think)
for (variable for counting; number of loops; Increments or decrements){
//Code here
}

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

What is a for loop used for?

A

Easy way to count how many times you ran a program/you can tell it how many times to run.

while loop, you gotta do more stuff to do that is annoying… tbh its prob easier to use while loops.

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

What is an if statement?

A

Sadly, the name gives it away

it’s a set of commands given and executed due to the value of the condition on the if, and else if. The else at the end is like a default in a switch statement.

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

Structure of an if statement.

A

if (Condition) {
//Code here
}
else if (Condition) {
//Code here
}
else {
//Code here
}

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

Try-Catch Block? So like why does it exist?

A

A Try Catch Block is a made so that you can catch things like errors before it breaks your program. The one we learnt is the one for errors.

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

Try-Catch for any error structure.

A

try
{
//Code you want to make sure doesn’t break
{
catch(Exception e)
{
//What happens when there is an error?
}

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

Ok ok ok methods
So like why? Why make methods?

A

Why make functions in math? Well, so that you can see all the values and not just one. Also, it gets very useful and it is used everywhere.

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

What is a public static void mainbalablabla???????!?!?!?!?

A

So like java is object-oriented and that’s why agam doesn’t wanna learn it.

C
Printf(“”);

Java
public static void main(string[] arg){
System.out.println(“”);
}

17
Q

What is void?

A

It means that everything in the method, if called, will run.

18
Q

What is a type that is returned?

A

So a return type is a Method that, when called, will give you whatever the type is.
For example:
public static int(){
int x = 4;
return x;
}

19
Q

What are parameters?

A

Parameters are Information given when calling a method. This is like math kinda… When you give y as 3 it gives you x as 6.