| preferred AP College board partner for AP classes
AP Computer Science A/Unit 5: Writing Classes
Start Practice TestPractice Test
About Exam
easy
Object Instantiation and Method Call
< Prev
Next >

Which of the following lines correctly completes the missing code so that an object of GradePointAvg is created and its calculateGPA method is called?

public class Driver {
    public static void main(String[] args) {
        // Missing line: Instantiate GradePointAvg and call calculateGPA
        // [Missing Line]
    }
}

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

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

B

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

C

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

D

System.out.println(GradePointAvg.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: [email protected]|Privacy Policy