← Quiz: Nested and Anonymous Classes: all 10 questions
Quiz: Nested and Anonymous Classes · Question 2 of 10
How do you create an object of the inner (non-static) class Account inside Bank?
How do you create an object of the inner (non-static) class Account inside Bank?
- A.
new Bank.Account(500) - B.
Bank.new Account(500) - C.
bank.new Account(500)wherebankis a Bank object - D.
new Account(bank, 500)is the only way
Answer & explanation
Correct answer: bank.new Account(500) where bank is a Bank object
Each inner object must be linked to an outer object, so you create it through one.
Can you get the rest right without peeking?
Take the timed Quiz: Nested and Anonymous Classes quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →