Lecture No 10 Updated
Lecture No 10 Updated
10
interface <interface-name>
{
// declare constants
// declare abstract methods
}
@Override
public void makeSound() {
System.out.println("Dog barks");
}
}
When a class implements an interface that inherits another interface, it must provide an
implementation for all methods required by the interface inheritance chain.
interface ParentInterface {
void m1();
void m2();
}
11
Abstract class in java
• A class which contains the abstract keyword in its declaration is called abstract
class.
• Note: Object of abstract class can not be instantiated but reference because
every super class contains the capability to store the object of sub class.
Example
Interface Abstract
Contains only abstract methods. Contains both abstract and non-abstract methods.
interface keyword is used to declare interface. abstract keyword is used to declare abstract class.