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
easy Solved by 39 students

Primitive Type Arithmetic Calculation

< Prev
Next >

Which of the following statements can replace the /* missing statement */ so that convertToSeconds works as intended?

Consider the method convertToSeconds, which is intended to calculate the total time in seconds for a given number of hours and minutes.

For example, the following scenarios demonstrate the expected behavior of convertToSeconds:

convertToSeconds(1, 30) = 5400
convertToSeconds(2, 15) = 8100

The current implementation of convertToSeconds is incomplete:

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

Which of the following statements can replace the /* missing statement */ so that convertToSeconds 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
Mark for review

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Total Time
Score
#1varunrajaram111 0m 00s 100
#2l.alzahrani0411 0m 00s 100
#3tttttt33232311 0m 01s 99
#4liuwilliam07241011 0m 21s 79
#5patrickmeijer00911 0m 29s 71
#6ragulk1412200611 0m 30s 70
#7yeee586411 0m 30s 70
#86test6ing622 2m 13s 67
#9leftoverjluck11 0m 37s 63
#10busemagngr11 0m 38s 62
Items per page:
10
1 – 10 of 32

AI Tutor

How can I help?

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