I have a doubt like i have read we can't override private methods here i can override my private method showAge method it is not showing any error . update me if i am wrong.
class parent {
int age = 26;
private void showAge() {
System.out.println("age:" + age);
}
}
public class Inheritance extends parent{
String name = "karthik";
void showName() {
System.out.println("Name :" + name);
}
void showAge() {
System.out.println("child age:" + age);
}
public static void main(String args[]) {
Inheritance i = new Inheritance();
i.showAge();
i.showName();
i.age = 16;
i.name = "surya";
i.showAge();
i.showName();
}
}