| 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 18 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 = “studentName”, grade = studentGrade, gpa = 0.0

B

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

C

name = null, grade = 0, gpa = 0.0

D

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

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

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Time
Score
#1Ishaan.m.kurup23 0m 00s 190
#2songqiuhui201222 0m 57s 143
#3sgarv251311 0m 00s 100
#4sailajavadlamani3311 0m 00s 100
#5dinhhoa12 0m 00s 90
#6y.seong202711 0m 32s 68
#7psak1211 0m 47s 53
#8varunrajaram111 1m 25s 15
#9suhanakochhar00611 3m 36s -116
#10chunxiangxu.cxu01 2m 16s -146
Items per page:
10
1 – 10 of 11
No comments yet. Be the first to comment!

AI Tutor

How can I help?

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