101-110 Flashcards
What is a classloader?
A classloader is a subset of JVM that is responsible for loading class files.
There are 3 built in classloaders:
1. Boot strap Classloader
2. Extension classloader
3. System/Application Classloader
What is a map in Java?
A map is an interface of the Util package which maps unique keys to values. it isn’t part of the collections package so has a few different characteristics. E.g it doesn’t allow duplicate keys and each key can map at max one value
What is runtime polymorphism?
The process in which to call an overridden method is done at compile-time. In this process, an overridden method is called through the reference variable of a superclass
Difference between abstract classes and interfaces?
- An interface can’t provide any code at all.
- A class may implement several interfaces but may only extens one abstract class
- All methods in an interface are abstract.
- Every class that implements an interface must have all the methods in that interface defined
- An interface can’t contain constructors
- Interfaces are slow as it requires extra indirection
Why doesn’t Java support multiple inheritance?
If a child class can inherit from multiple parent classes it becomes difficult to choose which parent class’s method to use, if multiple parent classes have the same method name. Therefore a class is only allowed to extend from one other class.
What is an association?
Association is a relationship where all objects have their own lifecycle and there is no owner. For example when a teacher can have multiple students and a student can have multiple teachers as there is no ownership between the two.
What is meant by aggregation?
An aggregation is a specialized form of association where all objects have their own lifecycle but there is ownership and a child object can’t belong to another parent object. Like how a teacher can’t belong to multiple departments.
What is composition in Java?
Composition is a form of aggregation. This is where a child object doesn’t have their own lifecycle and if a parent object is deleted the child object will also be deleted. For example if you destroy a house you destroy its rooms.
What is a marker interface?
A marker interface is defined as an interface having no data member and member functions. Essentially an empty interface. E.g. Serializable interface, Clonable interface