U2: Summative Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

Counters and Scores

A

Use technique variable = variable + 1 for adding score

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

Variables using Custom Data Types (Classes)

A
  • All programs written in Java contain classes
  • Examples of custom data types: Strings from String Class, Scanner from Scanner Class
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

Predefined Subprograms

A
  • Pre-existing program allowing task to be accomplished quickly
  • Ex: Math.round(), Integer.ParseInt()
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Random Numbers

A
  • randomNumber = (int)Math.round(Math.random()*[n-1]+1)
  • Generates between 1 and n
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Creating Random Object

A
  • Random random = new Random()
  • Written at start of program to allow random values to come
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

Casting a Value to Double

A
  • Add (double) at the left of variable
  • Ex: int numCorrect; (double) numCorrect
  • Can cast to integer, other value as well
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

break (code)

A

Ends a program

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

.equals Subroutine

A
  • Used for strings instead of the == sign
  • Ex: if (variable1.equals (variable2))
How well did you know this?
1
Not at all
2
3
4
5
Perfectly