Skip to main content

All Questions

Filter by
Sorted by
Tagged with
2 votes
5 answers
1k views

What is an example of class inheritance in every-day life which is easy to write in an object-oriented language?

When a student is first learning about class inheritance it is nice to use an example from every-day life. For example, Plastic Cups are ...
3 votes
3 answers
519 views

What's a good example of a static factory method returning instances of subclasses?

One benefit of having a class provide a static factory method rather than public constructors is the method can return an instance of a subclass. For example, if the class ...