Professional Documents
Culture Documents
Tamim Hasan Saykat 2022 1 60 289 5
Tamim Hasan Saykat 2022 1 60 289 5
Student id :2022-1-60-289
...........................................................................................................................................................................................
interface Printable {
Printable printable;
printable = printerA;
printable.display("Hello Interface");
printable = printerB;
printable.display("Hello Interface");
..........................................................................................................................................................................
interface MyInterface {
mc1.print("Hello World");
mc1.greet();
mc2.print("Hello Java");
mc2.greet();
mc2.specialGreet();
..........................................................................................................................................................................
interface Animal {
void makeSound();
void giveBirth();
void fly();
System.out.println("Dog barks");
}
}
System.out.println("Sparrow chirps");
System.out.println("Sparrow flies");
dog.makeSound();
dog.giveBirth();
sparrow.makeSound();
sparrow.fly();
..........................................................................................................................................................................................
interface Swimmer {
void swim();
interface Flyer {
void fly();
}
class Duck implements Swimmer, Flyer {
System.out.println("Duck swims");
System.out.println("Duck flies");
System.out.println("Airplane flies");
duck.swim();
duck.fly();
airplane.fly();
...................................................................................................................................................................
interface MyInterface {
System.out.print("[Interface] ");
myClass.printMessage("Hello, World!");
myClass.printFormattedMessage("Formatted message");
...................................................................................................................................................................
interface MathOperations {
return a + b;
return a - b;
}
public class InterfaceStaticMethodExample {