인터페이스가 갖고 있는 객체지향의 특징

Ryan mingun choi·2023년 10월 20일
0

인터페이스특징

  1. 추상화 - 인터페이스를 사용하면 구현 세부정보를 지정하지 않고 메서드정의가 가능
  1. 다중상속 - 클래스는 여러소스에서 동작 및 기능을 상속 할 수 있으므로 코드 재사용 및 유연성이 높아짐
      public interface GPS {
          public void getCoordinates();
      }

      public interface Radio {
          public void startRadio();
          public void stopRadio();
      }

      public class Smartphone implements GPS,Radio {
          public void getCoordinates() {
              // return some coordinates
          }
          public void startRadio() {
            // start Radio
          }
          public void stopRadio() {
              // stop Radio
          }
      }
  
profile
finding happiness

0개의 댓글