Object-oriented design
Language rules interviewers like
Abstract class versus interface, static, constructors, virtual functions and object lifetime.
In two minutes
One idea to a line
An abstract class can hold state and partly implemented methods; a class can extend only one. An interface lists what a type can do and a class can implement many.
A static member belongs to the class, not to an object, and is shared by all objects. A static method has no `this`.
In C++ a function is chosen by the real type only if it is virtual. A class that is deleted through a base pointer needs a virtual destructor.
A copy constructor makes a new object from an existing one. A shallow copy copies pointers, so two objects share the same memory; a deep copy duplicates what they point to.
Java and Python free objects with garbage collection; C++ frees them when you delete them or when a stack object leaves its scope.
Slips people make here
Interviewers know them too
Forgetting `virtual` on the destructor of a base class.
Saying an interface can never have any code: modern interfaces may have default methods.
Treating a shallow copy as independent.
Your practice here
Not started
12 written questions
No answers yet