Class Part2_InheritanceWithDefaults
java.lang.Object
Part2_InheritanceWithDefaults
Demonstrates inheritance-based polymorphism where a concrete default
method is inherited unchanged alongside an abstract method that must
be overridden.
Disassembled bytecode (javap -c):
Compiled from "Part2_InheritanceWithDefaults.java"
public class Part2_InheritanceWithDefaults {
public Part2_InheritanceWithDefaults();Code:0:aload_0 1:invokespecial#1 // Method java/lang/Object."<init>":()V
4:return
public static void makeSleep(AbstractAnimal);
Code:
0: aload_0
1: invokevirtual #7 // Method AbstractAnimal.sleep:()V
4: return
public static void main(java.lang.String[]);
Code:
0: new #12 // class DogWithDefault
3: dup
4: invokespecial #14 // Method DogWithDefault."<init>":()V
7: astore_1
8: aload_1
9: invokestatic #15 // Method makeSleep:(LAbstractAnimal;)V
12: return
}
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic voidstatic voidDynamic Dispatch using abstract parent reference.
-
Constructor Details
-
Part2_InheritanceWithDefaults
public Part2_InheritanceWithDefaults()
-
-
Method Details
-
makeSleep
Dynamic Dispatch using abstract parent reference.- Parameters:
aa- abstract-typed reference;sleep()is a non-overridden, inherited default method shared by every subclass.
-
main
-