I am so confused in this topic. //a class (lets say B) extendes or implements another class or interface respectively
interface myInterfaceA{
int interfaceDataMember1;
int interfaceDataMember2;
void interfaceMethod1();
void interfaceMethod2();
}
class myClassA{
int parentClassDataMember1;
int parentClassDataMember2;
myclassA(){}
void parentClassMethod1(){}
void parentClassMethod2(){}
}
//case1
class B implements myInterfaceA{
int dataMember1;
int dataMember2;
B(){}
void method1(){}
void method2(){}
}
// OR case2
class B extends myClassA{
int dataMember1;
int dataMember2;
B(){}
void method1(){}
void method2(){}
}
// so in either case what is the purpose of creating the object of class B in the following way
myInterfaceA objectB = new B();
// or
myClassA objectB = new B();
1) is there any name of this procedure? 2) what (data memeber, methods, constructor ) will be loaded in objectB? 3) if all the code of class B will be loaded in the objectB then why did we give the refrece of interface or parent class? 4) is this shows polymorphism? if yes, then why? 5) in case2 will class B also inherit the constructor of myClassA 6) why the constructor of parentclass is also called whe we create child class object