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