101-110 Flashcards

1
Q

What is a classloader?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What is a map in Java?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is runtime polymorphism?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Difference between abstract classes and interfaces?

A
  1. An interface can’t provide any code at all.
  2. A class may implement several interfaces but may only extens one abstract class
  3. All methods in an interface are abstract.
  4. Every class that implements an interface must have all the methods in that interface defined
  5. An interface can’t contain constructors
  6. Interfaces are slow as it requires extra indirection
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

Why doesn’t Java support multiple inheritance?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What is an association?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is meant by aggregation?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is composition in Java?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What is a marker interface?

A

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

How well did you know this?
1
Not at all
2
3
4
5
Perfectly