| preferred AP College board partner for AP classes
AP Computer Science A/Unit 2: Using Objects
Start Practice Test
Share
easy Solved by 9 students
Java Constructor Overloading
< Prev
Next >

Identify, using its signature, the correct constructor being called.
Consider the following class definition:

public class BankAccount {
    private String owner;
    private double balance;
    
    public BankAccount(String name) {
        owner = name;
        balance = 0.0;
    }
    
    public BankAccount(String name, double amount) {
        owner = name;
        balance = amount;
    }
    
    public double getBalance() {
        return balance;
    }
}

Which of the following constructor calls will result in a BankAccount object with a balance of 0.0?

A

BankAccount account = new BankAccount();

B

BankAccount account = new BankAccount(“John”, 100.0);

C

BankAccount account = new BankAccount(“John”);

D

BankAccount account = new BankAccount(“John”, 50.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
#1kaisuki11 0m 00s 100
#2richa.tuli24 4m 01s -61
#3lsj0803092211 6m 41s -301
#4jeonsaw172311 7m 08s -328
#5y.seong202712 11m 31s -601
APFIVE © 2020.
Email: [email protected]|Privacy Policy