| preferred AP College board partner for AP classes
easy Solved by 8 students
Static vs Instance Variables
< Prev
Next >

Develop code to declare the class variables that belong to the class.
Consider this partial class definition:

public class BankAccount {
    private double balance;
    private static double interestRate;
    private static int nextAccountNumber = 1000;
    
    // constructor and methods not shown
}

Which statement about these variable declarations is correct?

A

All three variables are accessible from static methods without creating an object instance

B

nextAccountNumber should be declared as an instance variable since each account needs a unique number

C

interestRate and nextAccountNumber are shared by all BankAccount objects, while balance is unique to each object

D

balance and interestRate are instance variables, while nextAccountNumber is a class variable

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.kurup25 0m 00s 170
#2songqiuhui201222 0m 32s 168
#3sailajavadlamani3311 0m 00s 100
#4sgarv251311 0m 00s 100
#5y.seong202701 1m 36s -106
#6suhanakochhar00614 7m 34s -384
APFIVE © 2020.
Email: [email protected]|Privacy Policy