Advertisement
Swampert420

Untitled

Jul 30th, 2022
842
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 0.60 KB | None | 0 0
  1. package Interface;
  2.  
  3. interface A {
  4.     public void display();
  5.     default void display2(){
  6.         System.out.println("Default access specifier");
  7.     }
  8. }
  9.  
  10. interface C extends A{
  11.     public int square(int a);
  12. }
  13.  
  14. class B implements A {
  15.     @Override
  16.     public void display(){
  17.         System.out.println("Display method");
  18.     }
  19.    
  20.     public int square(int a){
  21.         return a*a;
  22.     }
  23. }
  24.  
  25. public class MainClass {
  26.  
  27.     public static void main(String[] args) {
  28.         B b = new B();
  29.         b.display();
  30.         b.display2();
  31.         System.out.println(b.square(6));
  32.     }
  33. }
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement