Varriables Flashcards

1
Q

What is a “boolean” data type?

A

In Java, thebooleanprimitive data type is used to store a value, which can be eithertrueorfalse

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

What is a String variable?

A

A String in Java is a Object that holds multiple characters. It is not a primitive datatype.

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

How do you create a String?

A

A String can be created by placing characters between a pair of double quotes (“).

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

What is an “int” data type?

A

In Java, the int datatype is used to store integer values. This means that it can store all positive and negative whole numbers and zero. 3,4,0,-5 etc

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

How do you compare Strings?

A

To compare Strings, the equals() method must be used instead of the primitive equality comparator ==.

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

What is a “char” data type?

A

In Java, char is used to store a single character. The character must be enclosed in single quotes. char answer = ‘y’;

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

What are primitive data types?

A

Java’s most basic data types are known as primitive data types and are in the system by default.

The available types are as follows:

int = Holds whole numbers
char = Holds single characters
boolean = Holds true or false
byte =
long =
short =
double = Holds numbers with decimals 
float =
null = is another, but it can only ever store the value null
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is Static Typing in java?

A

In Java, the type of a variable is checked at compile time. This is known as static typing. It has the advantage of catching the errors at compile time rather than at execution time. Which means that every variable and every expression has a type that is known at compile time.

Variables must be declared with the appropriate data type or the program will not compile.

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

What are compound assignment “operators”?

A

Compound assignment operators can be used to change and reassign the value of a variable using one line of code. Compound assignment operators include +=, -=, *=, /=, and %=.

For example:

int number = 5;

number += 3; // Value is now 8
number -= 4; // Value is now 4
number *= 6; // Value is now 24
number /= 2; // Value is now 12
number %= 7; // Value is now 5
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

What are increment and decrement assignment “operators”?

A

The increment operator, (++), can increase the value of a number-based variable by 1 & the decrement operator, (–), can decrease the value of a variable by 1.

int numApples = 5;
numApples++; // Value is now 6

int numOranges = 5;
numOranges–; // Value is now 4

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

What does the “Final” keyword do?

A

When you use the “final” keyword on a variable the value will remain the same, and any attempts to change it later with operators will result in an error message.

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

What is the Order of Operations?

A
The order in which an expression with multiple operators is evaluated is determined by the order of operations: 
parentheses() -> 
multiplication* -> 
division/ -> 
modulo% -> 
addition+ -> 
subtraction
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are the Math Operations and which variables can they be applied to?

A

Basic math operations can be applied to int, double and float data types:

\+ addition
- subtraction
* multiplication
/ division
% modulo (yields the remainder)

These operations are not supported for other data types.

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

What are the Comparison operators and which data types can they be used with?

A

Comparison operators can be used to compare two values:

> greater than
< less than
>= greater than or equal to
<= less than or equal to
== equal to
!= not equal to
They are supported for primitive data types and the result of a comparison is a boolean value true or false
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is a Data type?

A

There are two kinds of data types in the Java programming language: primitive types and reference types. There are, correspondingly, two kinds of data values that can be stored in variables, passed as arguments, returned by methods, and operated on: primitive values and reference values.

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

What is a variable?

A

A variable can be thought of as a memory location that can hold values of a specific type.

The value in a variable may change during the life of the program—hence the name “variable.” … A variable that holds integers (whole numbers) has the data type Integer and is called an integer variable.

17
Q

What are the two reference types in java programming?

A

The types of the Java programming language are divided into two categories: primitive types and reference types.

18
Q

What are the primitive types?

A

The primitive types are the boolean type and the numeric types. The numeric types are the integral types byte, short, int, long, and char, and the floating-point types float and double.

19
Q

What are the reference types?

A

The reference types are class types, interface types, and array types.

20
Q

What is an object in Java?

A

An object is a dynamically created instance of a class type or a dynamically created array. For example we can create the class objects apple, orange, banana and an array object fruitBasket that can reference them.

Just like the world around us contains objects in a location we can create objects in java and have them stored in a location of memory.