Choosing how to earn college credit? CLEP vs AP guide
| preferred AP College board partner for AP classes
AP Computer Science A/Unit 3: Class Creation
Start Practice TestPractice Test
About Exam
easy

Object Instantiation and Method Call

Mark
< Prev
Next >

Consider the following class definitions. Which code segment, when substituted for // [Missing Line] in the main method, will correctly instantiate a GradePointAvg object and call its calculateGPA method?

public class Driver {
    public static void main(String[] args) {
        // [Missing Line]
    }
}

public class GradePointAvg {
    public double calculateGPA() {
        return 3.5;
    }
}
A

System.out.println(GradePointAvg.calculateGPA());

B

GradePointAvg avg = new GradePointAvg; System.out.println(avg.calculateGPA());

C

GradePointAvg avg = GradePointAvg(); System.out.println(avg.calculateGPA());

D

GradePointAvg avg = new GradePointAvg(); System.out.println(avg.calculateGPA());

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.

No comments yet. Be the first to comment!

AI Tutor

How can I help?

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