| 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 24 students
Java Arithmetic Expression Evaluation
< Prev
Next >

Consider the following incomplete calculateExpression method.

public static double calculateExpression(int a, int b, int c) {
    /* missing statement */
    return result;
}

The method is intended to work as demonstrated by these examples:

  • A call to calculateExpression(5, 4, 2) returns 10.0.
  • A call to calculateExpression(6, 3, 2) returns 9.0.

Which of the following statements, if substituted for /* missing statement */, will cause the method to work as intended?

A

double result = a / b * c + a;

B

double result = a + b * c - (a / c);

C

double result = (a * b) / c;

D

double result = a * (b - c) + a / c;

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
#110818526533 0m 18s 282
#2liuwilliam07241011 0m 28s 72
#3lsj0803092211 0m 42s 58
#4raufyildirim9511 0m 46s 54
#5hmbin99911 0m 58s 42
#6parth.taur22711 1m 04s 36
#7sarah.alyahya90tt01 0m 00s -10
#8geethasailaja23 4m 13s -63
#9bommasam00013 3m 12s -112
#10patrickmeijer00911 3m 43s -123
Items per page:
10
1 – 10 of 12
No comments yet. Be the first to comment!

AI Tutor

How can I help?

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