| preferred AP College board partner for AP classes
AP Computer Science A/Unit 1: Primitive Types
Start Practice TestPractice Test
About Exam
easy Solved by 46 students
Primitive Type Arithmetic Calculation
< 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
Time
Score
#1varunrajaram111 0m 00s 100
#2l.alzahrani0411 0m 00s 100
#3liuwilliam07241011 0m 21s 79
#4patrickmeijer00911 0m 29s 71
#5yeee586411 0m 30s 70
#66test6ing622 2m 13s 67
#7leftoverjluck11 0m 37s 63
#8raufyildirim9511 0m 46s 54
#9701704611 0m 46s 54
#10kshiva2009m11 0m 52s 48
Items per page:
10
1 – 10 of 26

AI Tutor

How can I help?

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