| preferred AP College board partner for AP classes
easy Solved by 11 students
Constructor and Instance Variable Initialization
< Prev
Next >

Consider the following class definition and object instantiation.

public class Student {
    private String name;
    private int grade;
    private double gpa;
    
    public Student(String studentName, int studentGrade) {
        name = studentName;
        grade = studentGrade;
        gpa = 0.0;
    }
}

Student s = new Student("Alice", 11);

What are the values of the instance variables for the Student object s after the code segment has been executed?

A

name = “Alice”, grade = 11, gpa = 0.0

B

name = “studentName”, grade = studentGrade, gpa = 0.0

C

name = “Alice”, grade = 11, gpa = null

D

name = null, grade = 0, gpa = 0.0

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

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Time
Score
#1Ishaan.m.kurup23 0m 00s 190
#2songqiuhui201222 0m 57s 143
#3sailajavadlamani3311 0m 00s 100
#4sgarv251311 0m 00s 100
#5dinhhoa12 0m 00s 90
#6y.seong202711 0m 32s 68
#7psak1211 0m 47s 53
#8suhanakochhar00611 3m 36s -116
APFIVE © 2020.
Email: apfive@apfive.org|Privacy Policy