Driver Class and Object Interaction
Which of the following is an example of a driver class correctly calling an object class based on the notes?
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 Driver class with a main method that instantiates a Calculator object and calls its ‘add’ method.
B
A Calculator class with the main method calling its ‘add’ method.
C
A main method that attempts to call ‘add’ without creating a Calculator instance.
D
A Driver class that does not instantiate any objects.
Question Leaderboard
Not enough data yet to show leaderboard.
APFIVE