Change example code style to show more constructs

Add a more complete code example that shows more constructs, including throws instruction, read-only fields, nested types and generics.