About Question enthuware.ocpjp.v8.2.1782 :
Posted: Sun Apr 11, 2021 11:21 am
I tested the code but changed the enum so that it was just:
but I thought this would cause:
to fail compilation since
static members: can use enclosing class' name
non-static members: must use instance of enclosing class
but it still worked.
And also if have:
it fails compilation regardless of whether the enum is static/non-static.
Is there an explanation for this? :/
Code: Select all
enum Genre { DRAMA, THRILLER, HORROR, ACTION }; //***i.e. not static
Code: Select all
new Movie("Titanic", Movie.Genre.DRAMA, 'U'),
new Movie("Psycho", Movie.Genre.THRILLER, 'U'),
new Movie("Oldboy", Movie.Genre.THRILLER, 'R'),
new Movie("Shining", Movie.Genre.HORROR, 'U'));
static members: can use enclosing class' name
non-static members: must use instance of enclosing class
but it still worked.
And also if have:
Code: Select all
new Movie("Titanic", new Movie().Genre.DRAMA, 'U'),
Is there an explanation for this? :/