Java supports single an multilevel inheritance. What does that mean?
A class cannot extent from more than one class directly, but it can use a hierarchy
What is Polymorphism?
Polymorphism is the ability to process data differently depending on their types of inputs -> Same method name but with different parameters
What is dynamic Polymorphism?
Child class overrides the parent’s method
What is static Polymorphism?
Polymorphism which is resolved at compile time and thus does away with runtime virtual table lookups -> Multiple methods in one class have the same name
What are possible problems with Polymorphism?
Type identification during downcasting and fragile base class problem
When to use inheritance instead of composition?
Inheritance is used if classes fulfil the “is-a” condition and mainly provide additive functionality further down the class hierarchy
When to use composition instead of inheritance?
Composition allows to model objects that are made up of other objects -> the object(s) that compose or are contained by one object are destroyed too when that object is destroyed
What does the variable scope define?
The variable scope defines where variables can be seen
What method modifiers exist in java? And what is the default modifier?
public, protected, private, and package-private. Default is package-private
What is the problem with comparing two objects with the == operator?
Comparing two objects with the == operator returns false because it is not the values that get compared but the memory spaces -> Comparable and Comparator Interface
What are characteristics of abstract classes?
What are typical scenarios where we should prefer abstract classes over interfaces and concrete classes?
What is an interface?
An interface is an abstract type that contains a collection of method and constant variables
Why are interfaces used?
Interfaces are used to achieve abstraction, polymorphism and multiple inheritances
What are characteristics of an interface?
What can we achieve by using interfaces?
What are the interface inheritance rules?
What is the difference between a class and an interface?
What is a functional interface?
A functional interface is an interface that contains only one abstract method
When to use an interface?
When to use an abstract class?
For what can the super keyword be used?
For what can the this keyword be used?
What is field shadowing?
Example: If constructor parameters have the same name as instance fields