r/programminghelp • u/Titanium_Shoulder • Mar 25 '24
Java Quiz Question
I had this question on a recent quiz. Should I ask my professor about it, because I believe the professor made a mistake. Here is the multiple-choice question:
1.) If you declare an array of objects of type BankAccount as follows:
BankAccount[] acts = new BankAccount[SIZE];
How many objects (not locations) get allocated from this statement?
Options:
- SIZE objects
- 0
- SIZE-1
- 1 (the array)
I chose the second option (0) and am confused on why it was marked incorrect.
2
Upvotes
View all comments
Show parent comment
1
u/jddddddddddd Mar 25 '24
It's been 20+ years since I last used Java, but if you asked me if an array in the language is an object, I'd say it probably isn't.
And it turns out both of us would be wrong, in Java arrays are objects apparently.