U3: Predefined Methods Flashcards
1
Q
Method [A]
A
- Has own name
- Action already written
- Stored in separate file “class” having name
2
Q
Method [B]
A
- Needs info to be sent
- Can return data to main program
- Can be executed from main program
3
Q
Passing Arguments
A
Information sent to a method
4
Q
Outputting Math Methods
A
System.outprintln(Math.method(num1, num2))
5
Q
max
A
- Maximum of two numbers
- int num1 = 34; int num2 = 12;
- Output: 34
6
Q
min
A
- Minimum of two numbers
- int num1 = 34; int num2 = 12;
- Output: 12
7
Q
pow
A
- First input to power of 2nd
- int num1 = 2; int num2 = 6;
- Output: 64
8
Q
abs
A
- Absolute value
- double num = -34.214;
- Output: 34.214
9
Q
hypot
A
- (num1^2 + num2^2)^½:
- int sideA = 4; int sideB = 3;
- Output: 5
10
Q
ceil
A
- Rounded up nearest integer
- double num = 82.114;
- Output. 82.0
11
Q
floor
A
- Rounded down nearest integer
- double num = 87.876
- Output: 87.0
12
Q
sqrt
A
- Square root of number
- double num = 64;
- Output: 8.0
13
Q
round
A
- Rounded to nearest integer
- double num = 64.545
- Output: 65
14
Q
random
A
- Positive double value between 0.0 and 1.0
- System.out.println(Math.random());
- Possible Output: 0.1311034762657053
15
Q
toDegrees
A
- Angle in radians to degrees
- double angle1 = 0.7853981633974483;
- Output: 45