Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
AP Computer Science A/Unit 1: Primitive Types
Start Practice TestPractice Test
About Exam
medium Solved by 51 students

Primitive Type Arithmetic Calculation

Mark
< Prev
Next >

Consider the following method, which is intended to convert a given number of hours and minutes into a total number of seconds.

public static int convertToSeconds(int hours, int minutes) {
    /* missing statement */
    return totalSeconds;
}

For example, convertToSeconds(1, 30) should return 5400, and convertToSeconds(2, 15) should return 8100. Which of the following code segments can replace /* missing statement */ so that the method works as intended?

A

int totalSeconds = (hours + minutes) * 60;

B

int totalSeconds = Math.abs(hours * 60 - minutes) * 60;

C

int totalSeconds = hours * 60 * 60 + minutes * 60;

D

int totalSeconds = (int) (hours * minutes * 60);

Hint
Did You Know?
Explain Why
Explain All Answers
Check Answer
Show Correct Answer
Report Question

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Total Time
Score
#1Wilbert.Ankomah2722 0m 48s 152
#2busemagngr22 1m 03s 137
#3varunrajaram111 0m 00s 100
#4l.alzahrani0411 0m 00s 100
#5tttttt33232311 0m 01s 99
#6liuwilliam07241011 0m 21s 79
#7mikaiya.beasley2711 0m 23s 77
#8patrickmeijer00911 0m 29s 71
#9ragulk1412200611 0m 30s 70
#10yeee586411 0m 30s 70
Items per page:
10
1 – 10 of 39

AI Tutor

How can I help?

APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy|