
can we inherit constructor ?if not then why yhis example is given class A { public A() { System.out.println("In A ctor"); } }
class B extends A {
public B() {
System.out.println("In B ctor");
}
public static void main(String [] args) {
B obj;
obj = new B();
}
}

Hi Priti , heare we are not inheriting the constructor. Hear we are inheriting instance members (variables & methods only) from A into B. In the above example A() for to create the object for A class and B() for just to creat the object for B class.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.