Variables Flashcards

1
Q

What is the rules when declaring a variable?

A

****How to declare and use a variable****

  • Variables must begin with a Alphabetical character
  • Can only use numbers, alphabetical characters + _
  • CANNOT BE A NAME THAT IS RESERVED WORD
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is the general structure of a java program?

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

What is the definition for variables

A

A symbol that holds a value that can be changed and maipulated

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

What is the int data type and how do you declare it?

A

int aInteger = 2121212121;

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

What is the double data type and how do you declare it?

A

double aDouble = 3.142;

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

What is the boolean data type?

A

boolean aBooleanValue = true;

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

What is the char data type?

A

char copyright = ‘\u00A9’;

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

What is the string data type

A

String aString = “Baby says that Joey is STOOPID “

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

How do you add two variables?

A

x += y;
x = x + y;

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

How do you subtract two variables

A

x -= y;
x = x - y;

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

How do you multiply two variables

A

x *= y;
x = x * y;

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

How do you divide two variables

A

x /= y;
x = x / y;

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

How do you mod two variables

A

x %= y;
x = x % y;

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

How do you perform a logical AND gate on two variables?

A

x &= y;
x = x & y;

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

How do you perform a logical OR gate on two variables

A

x |= y;
x = x| y;

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

What is constant?

A

final = declaring a constant

double = data type

pi = name of variable

```java
final double pi = 3.142
~~~

17
Q
A