Java 3

Overloading, Overriding (Java)

- 오버로딩(overloading) : 기존에 없는 새로운 매서드를 정의하는 것 - 오버라이딩(overriding) : 상속받은 메서드의 내용을 변경하는 것 ​ 출처: https://all-record.tistory.com/60 [세상의 모든 기록] 오버라이딩(Overriding) 오버라이딩이란? 부모 클래스로부터 상속받은 메서드의 내용을 변경하는 것을 오버라이딩이라 한다. 간단히 말하면 메서드를 다시 정의하는 것이다. 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 public clas all-record.tistory.com ​ 오버로딩(overloading) //Overloading.java class Overloading { void overloadinTest() ..

Java 2021.10.21

java 클래스 구현, 상속, 자동차 예제

//Car.java public class Car { private String carname; //차 이름 protected int speed; //차 속도를 수정해야하기 때문에 protected public Car() {} public Car(String carname) //생성자 { this.carname = carname; //차 이름 this.speed = 100; //차 속도 설정 (100이 기본) } public String getName() { return this.carname; } public int getSpeed() { return this.speed; } public void setSpeedUp() { speed += 10; } public void setSpeedDown() { ..

Java 2021.10.21

java 상속 관계 구조 구현(학생 예제)

//Student.java public class Student { private String student_name; //학생 이름 private int computer_grade; //컴퓨터 점수 public Student() {} public Student(String student_name, int computer_grade) //생성자 { this.student_name = student_name; //학생 이름 this.computer_grade = computer_grade; //컴퓨터 성적 설정 } public String getName() { return this.student_name; } public int getAverage() { return this.computer_grade; ..

Java 2021.10.21