I am a beginner in java programming language, recently I have studied that constructors can not be inherited in java, Can anyone please explain why<
you can't inherited constructors but you can inherit initialized value in constructor like
class test1 {
int a,b;
test1(){
a = 100;
b = 20;
}
}
class test2 extends test1 {
test2(){
// do something
}
}
class test {
public static void main(String[] args) {
test2 t = new test2();
int a = t.a;
int b = t.b;
System.out.println(a+b);
}
}