Are you taking CLEP classes? Try clep.ai
| preferred AP College board partner for AP classes
easy Solved by 7 students

Static vs Instance Variables

< Prev
Next >

Consider the following partial class definition.

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

Which of the following statements about these variable declarations is correct?

A

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

B

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

C

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

D

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

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

Question Leaderboard

Rank
User
Correct Count
Attempt Count
Total Time
Score
#1Ishaan.m.kurup25 0m 00s 170
#2songqiuhui201222 0m 32s 168
#3sgarv251311 0m 00s 100
#4sailajavadlamani3311 0m 00s 100
#5y.seong202701 1m 36s -106
#6suhanakochhar00614 7m 34s -384
#7bommasam00024 15m 14s -734
Items per page:
10
1 – 7 of 7
No comments yet. Be the first to comment!

AI Tutor

How can I help?

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