목록Java (30)
archive
1. 상속의 이점 -이미 잘 개발이 된클래스를 재사용해서 새로운 클래스를 만들기 때문에 중복되는 코드를 줄여 개발 시간을 단축시킴 -부모 클래스를 수정하면 모든 자식 클래스에 수정 효과를 가지고 오기 때문에 클래스의 수정을 최소화할 수 있음 2. 클래스 상속 -다른 언어와는 달리 자바는 다중 상속을 허용하지 않는다 -즉, 여러 개의 부모 클래스를 상속할 수 없기 때문에 extends 키워드 뒤에는 단 하나의 부모 클래스만 위치해야한다. public class 자식클래스 extends 부모클래스1, 부모클래스2{ ... } //부모클래스2는 올 수 없음 3. 부모 생성자 호출 -모든 객체는 생성자를 호출해야만 생성이 되기 때문에 부모 객체도 예외가 아님 -부모 생성자는 자식 생성자의 맨 첫 줄에 숨겨져있는..
1. 정적 멤버 -자바는 클래스 로더 (loader)을 이용해서 클래스를 메소드영역에 저장하고 사용하는데, 정적 멤버란 메소드 영역의 클래스에 고정적으로 위치하는 멤버를 말한다. -정적 멤버는 객체를 생성할 필요 없이 클래스를 통해 바로 사용이 가능하다. -필드와 메소드는 모두 정적 멤버가 될 수 있음, static 키워드를 추가해주면 된다. -객체마다 가지고 있을 필요성이 없는 공용적인 필드는 정적 필드로 선언하는 것이 좋음. 예를 들어 Calculator 클래스에서 원의 넓이나 둘레를 구할 때 필요한 파이는 Calculator객체마다 가지고 있을 필요가 없기 떄문에 정적 필드로 선언하는 것이 좋다. public class Calculator{ String color; // 계산기별로 색이 다를 수 있..
1. 클래스의 두 가지 용도 -라이브러리 클래스) 실행할 수 없으며 다른 클래스에서 이용하는 클래스 -실행클래스) main()메소드를 가지고 있는 실행 가능한 클래스 -Student 클래스는 라이브러리 클래스, StudentExample클래스는 실행 클래스 -일반적으로 자바 프로그램은 하나의 실행 클래스와 여러 개의 라이브러리로 구성, 실행 클래스는 실행하면서 라이브러리 클래스를 내부에서 이용한다. 2. 필드와 로컬변수의 차이점 *** 이 부분은 교수님 수업 시간에 확실하게 이해가 된 부분이지만 그래도 정리하면서 복습하자 - 로컬 변수는 생성자와 메소드 블록에서 선언되며 생성자와 메소드 호출 시에만 생성되고 사용된다 -필드는 클래스 블록에서 선언되며, 객체 내부에서 존재하고 객체 내외부에서 사용 가능하다..

1.The following code is the main method we want to run, and the following result is the corresponding console output. Declare the Rectangle class for this main method. package April06; public class Project01 { public static void main(String[] args) { // TODO Auto-generated method stub Rectangle r=new Rectangle(2,2,8,7); Rectangle s=new Rectangle(5,5,6,6); Rectangle t=new Rectangle(1,1,10,10); r...

1. We want to manage the scores of 5 students. If the inputs are the name and Korean, English, and mathematics scores for each student, we want to print the two-dimensional table including not only the name and all scores but also the sum and the average for each student adding the two columns. Then we want to add two rows to represent the sum and the average for each subject. Console Input: The..

1. Take no more than 10 integers and put them in an array, and compute the mean and variance of the integers. package March23; import java.util.*; public class Project1 { public static void main(String[] args) { System.out.println("10개의 정수를 입력하세요 >>>"); int[] arr= new int[10]; int sum=0; Scanner input=new Scanner(System.in); for(int i=0;i