Traits can contain members, methods and abstract methods
Class can inherit only one class but one class can use many traits.
Traits can be used to implement multiple behaviours in one class.
Declaring trait:
Using trait:
Result:
Explanation
line 29
the class Student
uses both of the templates.Student
class
inherits all of the traits members and functions.