Asagidaki kullanim dogru bir kullanim cunku burada kaltim duzgun gerceklestirilmis.
public class Animal{
public void sound(){
System.out.println("Huuuuuuuu");
}
}
public class Dog extends Animal{
@Override
public void soud() {
System.out.println("Hav Hav");
}
}
Asagidaki kullanim yanlis cunku kalitimda static method override olmaz.
public class Animal{
public static void sound(){
System.out.println("Huuuuuuuu");
}
}
public class Dog extends Animal{
//Exception static method override
@Override
public void soud() {
System.out.println("Hav Hav");
}
}
No comments:
Post a Comment