Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
AP Computer Science A/Unit 2: Using Objects
Start Practice TestPractice Test
About Exam
easy Solved by 12 students

Java Constructor Overloading

Mark
< Prev
Next >

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 statements will create a BankAccount object with a balance of 0.0?

A

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

B

BankAccount account = new BankAccount();

C

BankAccount account = new BankAccount(“John”);

D

BankAccount account = new BankAccount(“John”, 100.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
Total Time
Score
#1kaisuki11 0m 00s 100
#2Potter1611 0m 17s 83
#3bommasam00011 0m 18s 82
#4liuwilliam07241011 1m 17s 23
#5richa.tuli24 4m 01s -61
#6chunxiangxu.cxu12 3m 46s -136
#7lsj0803092211 6m 41s -301
#8jeonsaw172311 7m 08s -328
#9y.seong202712 11m 31s -601
#10pandasiteitei11 12m 14s -634
Items per page:
10
1 – 10 of 11

AI Tutor

How can I help?

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