상속 (2) 썸네일형 리스트형 [JAVA] 생성자와 상속 1234567package a; public class ConstructorDemo { public static void main(String[] args) { ConstructorDemo c = new ConstructorDemo(); }}Colored by Color Scriptercs 위의 예제는 에러를 발생시키지 않는다. ConstructorDemo 객체를 생성할 때 자동으로 생성자를 만들어주기 때문이다 12345678package a; public class ConstructorDemo { public ConstructorDemo(int param1) {} public static void main(String[] args) { ConstructorDemo c = new ConstructorDe.. [JAVA] 상속에 대한 기본 예제 1234567891011121314151617181920212223242526272829303132333435363738package a; class Calculator { int left, right; public void setOprands(int left, int right) { this.left = left; this.right = right; } public void sum() { System.out.println(this.left + this.right); } public void avg() { System.out.println((this.left + this.right) / 2); }} class SubstractionableCalculator extends Calculator {//exte.. 이전 1 다음