Beruflich Dokumente
Kultur Dokumente
Method Overloading
Generic Programming
Defining multiple methods with the same name but different signatures
within same class
Sometimes there are two or more possible matches for an invocation of a method,
but the compiler cannot determine the most specific match. This is referred to as
.
A class defines a .
A type defined by a subclass is called a and a type defined by its
superclass is called a
Circle is a subtype of GeometricObject and GeometricObject is a supertype
for Circle.
inheritance relationship enables a subclass to inherit features from its
superclass with additional new features
subclass is a specialization of its superclass; every instance of a subclass is
also an instance of its superclass,
every circle is a geometric object, but not every geometric object is a circle
}
m(new Object()); Polymorphism allows methods to be
public static void m(Object x) {
System.out.println(x.toString());
used generically for a wide range of
}
} object arguments. This is known as
class GraduateStudent extends Student {
}
Generic Programming.
class Student extends Person {
public String toString() {
return "Student";
}
}
class Person extends Object {
public String toString() {
return "Person";
}
}
Student b = (Student)o