| 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
< 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(“John”);

C

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

D

BankAccount account = new BankAccount();

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
#1kaisuki11 0m 00s 100
#2bommasam00011 0m 18s 82
#3liuwilliam07241011 1m 17s 23
#4richa.tuli24 4m 01s -61
#5chunxiangxu.cxu12 3m 46s -136
#6lsj0803092211 6m 41s -301
#7jeonsaw172311 7m 08s -328
#8y.seong202712 11m 31s -601
#9zgj0731041711 18m 08s -988
Items per page:
10
1 – 9 of 9
No comments yet. Be the first to comment!

AI Tutor

How can I help?

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