Can we initialize an object with the help of constructor of another class?
class1 object = new class2();
As long as
class2 extends (or implements in case of an interface)
class1 that is fine. For example,
List<String> list = new ArrayList<>();
To be clear, you are creating an instance of
ArrayList from my example). It just so happens that you have declared your variable to be of type