test2 Flashcards

1
Q

curly braces or the _____ _____ _____ can control the scope of a vriable

A

SCOPE INDEX OPERATORS

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

what is a variable?

A

a storage location in a computer’s ram memory

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

a variable has a ____ and a ____ ____ specified

A

name (identifier, reference, handle) and data type(int,String)

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

what do we do when we declare a variable

A

we specify its data type and name

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

what is the assignment operator

A

=

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

When we declare a variable, we’re ______ the name of the variable to a particular memory location address

A

binding

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

How must a Java variable identifier must start with

A

a letter, and underscore or a $ sign

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

True or false: You cannot start a variable name with a digit such as 3 or 7.

A

True it causes a compile error

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

is java case sensitive?

A

yes

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

can you use java reserved words or keywords such as public, class or else identifiers?

A

nope compile error

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

java names begin with a ____

A

lower case letter

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

how is the second word in a variable name written out

A

with a capital letter, camelBack

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

true or false. in java our programs statements are always contained inside a class file

A

true

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

class names always start with a

A

capital letter and each new word also starts with a capital letter

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q
variable names start with a \_\_\_\_ case letter
class names start with a \_\_\_\_ case letter
A

lower (camelBack)

upper (title case)

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

why do we specify the data type when we declare a variable?

A

tells os how many bytes of memory is needed for that variable and BC program uses data type to interpret the data that is stored

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

True or false: ASCII and Unicode: first 256 values are identical

A

true

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

do primitive data types have methods associated with them?

A

nope

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

how many primitive data types are there in java

A

8

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

what is mantissa and exponent

A

mantissa is the first part of an exponent the number that is going to be multiplied by 10 to the exponent. exponent is what it is

21
Q

is a string an object

A

yes

22
Q

what is a method in java

A

a method is some lines of code that are put in their own code block (inside their own curly braces) and this block is given a method name

23
Q

T or F: Var keyword only be used when created local variables within a method

A

True

24
Q

how are constants declared

A

with the keyword final along with its data type that it will hold

25
Q

constants can be declared on one line and initialized later on in another line

A

true

26
Q

what is a data literal

A

a data literal is an actual data value that appears in a program. its the value that is declared

27
Q

if you divide an integer by another integer does java give you an integer answer?

A

yes

28
Q

when dividing an integer literal by another integer java will do what to the decimal portion

A

truncate

29
Q

are primitive data types objects?

A

nope

30
Q

integer primitive data types

A

byte(8)m short(16), int (32), long(64)

31
Q

floating data types

A

float and double

32
Q

char is a single word

A

nope letter

33
Q

what are the binary operators

A

+ - * / %

34
Q

the answer of a modulus division operation is the ______ of value from a regular division operation

A

REMAINDER

35
Q

equals we use ___ and not equal is ____

A

== and !=

36
Q

by default a numeric literal value is assumed to be ____

A

positive

37
Q

increment operator

decrement operator

A

++

38
Q

True or false: An if structure is a single-selection type of structure because it either selects to carry out, or it ignores, a single action.

A

True

39
Q

should you put curly braces around every if block statement, even if there is only 1 statement to execute

A

yes, good coding style

40
Q

The logical AND indicates that both conditions must be truein order for the overall if expression to return a value of ____.

A

true

41
Q

if either condition is false, or both are false, then the overall if expression evaluates to ____

A

false

42
Q

true or false: the only way to get a true result from a logical and operation is for both conditions to be true

A

True

43
Q

Why do we use the && and || symbols when & and | seem to do the same thing?

A

The single ‘&’ AND operator is the ‘bitwise’ operator. It compares the corresponding bits of each operand to determine the overall true or false result. So, it does both comparisons, no matter what the first comparison return
but the && || will stop after reading a false value- saves a few cpu cycles

44
Q

declaring a variable

A

defining its type

45
Q

initializing a variable

A

specify the value to be stored in the variable

46
Q

4 rules of naming variables

A

1 start with letter or underscore
2. can’t use ? or %, spaces
3 variable names are case sensitive
4 you cannot use reserved words such as double or class as names

47
Q

what are two downsides of using objects such as BigDecimal and BigInteger in calculations?

A

slow and you have to call in methods called add, subtract and multiply

48
Q

what is a package and what does it contain

A

it is a collection of classes with a related purpose

49
Q

how do you tell in java code that a character should be interpreted as a character literal?

A

single quotes ‘ ‘