OOP Basics III Flashcards
Which overrides? The methods of a trait, or similarly-named inherited methods of a parent class?
Methods of a trait.
Which overrides? The methods of a class, or similarly-named methods of a trait?
Methods of a class.
What is the ‘insteadof’ keyword?
‘Insteadof’ is used to specify which trait’s methods should be used in a name conflict.
What is the ‘as’ keyword?
‘as’ is used to assign alias names to conflicting trait methods.
Can traits access private properties or methods of composing classes?
Yes.
Can composing classes access the private methods and properties of traits?
Yes.
Traits are essentially language-assisted __ _ __.
copy and paste
Can traits include abstract methods?
Yes.
Traits are a mechanism for __ __ in single inheritance languages.
code reuse
Can you instantiate a trait on its own?
No.
Traits are the application of class members without requiring __.
inheritance
How do you insert multiple traits into a class?
As a comma-separated list.
What happens when two traits insert a method with the same name?
A fatal error is produced.
The ‘as’ syntax can also be used to adjust…
…the visibility of a method.
Static variables can be referred to in trait methods, but cannot be __ _ _ __.
defined by the trait