| preferred AP College board partner for AP classes
AP Computer Science A/Unit 5: Writing Classes
Start Practice TestPractice Test
About Exam
easy Solved by 12 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

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

B

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

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
Report Question

Question Leaderboard

Rank
User
Correct Count
Attempt Count
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