Basic Java Program Flashcards

1
Q

Identifier:

A

A name given to an item in your program.

  • must start with a letter or _ or $
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are examples of legal names for a program?

A
  1. _myName
  2. TheCure
  3. ANSWER_IS_42
  4. $bling$
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What are examples of illegal names for a program?

A
  1. me+u
  2. 49ers
  3. side-swipe
  4. Ph.D’s
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

List out keywords in java that cannot be used as an identifier (a - c):

A
  1. abstract
  2. boolean
  3. break
  4. btye
  5. case
  6. catch
  7. char
  8. class
  9. const
  10. continue
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

List out keywords in java that cannot be used as an identifier (d - g):

A
  1. default
  2. do
  3. double
  4. else
  5. extends
  6. final
  7. finally
  8. float
  9. for
  10. goto
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

List out keywords in java that cannot be used as an identifier (i - n):

A
  1. if
  2. implements
  3. import
  4. instanceof
  5. int
  6. interface
  7. long
  8. native
  9. new
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

List out keywords in java that cannot be used as an identifier (p - s):

A
  1. package
  2. private
  3. protected
  4. public
  5. return
  6. short
  7. static
  8. strictfp
  9. super
  10. switch
  11. synchronized
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

List out keywords in java that cannot be used as an identifier (t - w):

A
  1. this
  2. throw
  3. throws
  4. transient
  5. try
  6. void
  7. volatile
  8. while
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

define escape sequence:

A

A special sequence of characters used to represent certain special characters in a string.

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

\t represents:

A

tab character

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

\n represents:

A

new line character

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

" represents

A

quotation mark character

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

\ represents

A

backslash character

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

What are the two ways to make comments in a code?

A
  1. //

2. /* (to start) and */ (to end)

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

define type:

A

A category or set of data values

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

define int:

A

integers to 2^31

Examples:
42, -3, 0, 926394

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

define double:

A

real numbers to 10^308

Examples:
3.1, -0,25, 9, 9.4

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

define char:

A

single text characters

Examples:
‘a’, ‘x’, ‘?’, ‘\n’

19
Q

define boolean:

A

logical values

Examples:
True, false

20
Q

define operator:

A

combines multiple values or expressions

21
Q

define the operator /

22
Q

define the operator %

A

modulus (a.k.a. remainder)

23
Q

What code is necessary to accept user input?

A

Scanner (input name) = new Scanner(System,in);

Scanner Dev = new Scanner (System.in);

24
Q

Define Scanner class method: nextDouble();

A

Retrieves input as a double

25
Define Scanner class method: nextInt();
Retrieves input as an int
26
Define Scanner class method: nextLine();
Retrieves the next line of data and returns it as a String
27
Define Scanner class method: next();
Retrieves the next complete token as a String
28
Define scope:
The part of a program where a variable exists. - From its declaration to the end of the { } braces
29
Math.abs (value) represents:
absolute value
30
Math,ceil (Value) represents:
rounds up
31
Math.floor (Value) represents:
rounds down
32
Math.max (Value1, value2) | represents:
larger of two values
33
Math.min (value1, value2) represents:
smaller of two values
34
Math.random () represents:
random double between -0 and 1
35
Math.round (value) represents:
nearest whole number
36
What is operator == represent?
Equals Ex. 1 + 1 == 2/TRUE
37
What is operator != represent?
Does not equal Ex. 3.2 != 2.5/TRUE
38
What is operator < represent?
less than Ex. 10 < 5/FALSE
39
What is operator > represent?
Greater than Ex. 10 > 5/ TRUE
40
What is operator <= represent?
less than or equal to Ex. 126 <= 100/FALSE
41
What is operator >= represent?
greator than or equal to Ex. 5.0 >= 5.0/TRUE
42
&& operator represents:
and Ex. (2 == 3) && (-1 < 5) FALSE
43
|| operator represents:
or Ex. (2 == 3) || ((-1 < 5) TRUE
44
! operator represents:
not Ex. !(2 == 3) TRUE