Professional Documents
Culture Documents
Lecture13 PDF
Lecture13 PDF
Inherited
capability
Child
1 2
Final Members: A way for Preventing Final Classes: A way for Preventing
Overriding of Members in Subclasses Classes being extended
All methods and variables can be overridden by
3 4
Circle Rectangle
7 8
Summary
Java supports this is through the keyword “final”.
This is applied to classes.
Interfaces
<<Interface>>
Example:
Politician Priest Lecturer
interface Speaker {
speak() speak() speak() public void speak( );
}
15 16
}
class ClassName implements InterfaceName [, InterfaceName2, …]
{
// Body of Class class Lecturer implements Speaker {
} public void speak(){
System.out.println(“Talks Object Oriented Design and Programming!”);
}
}
17 18
Inheritance and Interface
Extending Interfaces
Implementation
19 20
23 24
Summary Summary
Instance variables occur in each instance of a and variables of another class by subclassing,
class declaring that class in its extends clause.
Objects created with the new keyword class. It is the root of the Java hierarchy.
25 26
Summary Summary
From a subclass, you can explicitly invoke an by declaring it in its implements clause, and
overridden method of the superclass with the providing a method body for each abstract
super keyword. method.
27 28