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

Driver Class and Object Interaction

Mark
< Prev
Next >

Consider the two classes shown below. Which of the following statements accurately describes the code?

public class Driver {
    public static void main(String[] args) {
        Calculator calc = new Calculator();
        System.out.println(calc.add(5, 7));
    }
}

public class Calculator {
    public int add(int a, int b) {
        return a + b;
    }
}
A

A main method that attempts to call ‘add’ without creating a Calculator instance.

B

A Driver class that does not instantiate any objects.

C

A Calculator class with the main method calling its ‘add’ method.

D

A Driver class with a main method that instantiates a Calculator object and calls its ‘add’ method.

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

Question Leaderboard

Not enough data yet to show leaderboard.

AI Tutor

How can I help?

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