Exceptions

ArrayIndexOutOfBoundsException 배열의 범위를 벗어난 접근할 때 발생

ArithmeticException 산술 연산 오류 에 의해 발생 (예를 들어, 0으로 정수를 나누는 경우)

NullPointerException null 객체를 사용하려고 시도할 때 발생

ClassCastException 변환할 수 없는 클래스로 객체 변환을 시도할 때 발생

NumberFormatException String을 숫자(number)로 변환할 수 없을 때 발생 (예를 들어, “1.23”을 Integer 변환을 시도할 때)

IllegalArgumentException 메소드 인자(argument) 유형을 잘못 사용할 경우

InputMismatchException (Scanner 클래스) 잘못된 입력일 때 발생

IOException 입출력(IO) 오류에 의해 발생

FileNotFoundException 지정된 경로에서 파일을 찾지 못할 때 발생

Abstract class vs interface

abstract class vs interface

(Image from http://alecture.blogspot.com/2011/05/abstract-class-interface.html)

abstract class (일반변수+일반메소드+추상메소드 형태) – 추상클래스는 공통부분(abstract)을 상속해서 구현하게 함.
interface (상수+추상메소드 형태) – 기능(abstract) 구현(implements)을 강제함으로써, 구현한 객체들에서 동일한 동작을 보장할 수 있음.

An abstract class is generally used as a building basis for similar classes. Implementation that is common for the classes can be in the abstract class.
An interface is generally used to specify an ability for classes, where the classes doesn’t have to be very similar.

https://beginnersbook.com/2013/05/abstract-class-vs-interface-in-java/
https://dzone.com/articles/java-interface-vs-abstract-class
https://www.guru99.com/interface-vs-abstract-class-java.html

lab3

java2-lab3

Lab3_1~ Lab3_4 프로젝트 디렉토리 안에 모든 파일(src/*.java & bin/*.class)와 보고서 (장수제한없음)를 넣고 Lab3_학번_이름.zip 압축한 후 e-learning (http://lms.dankook.ac.kr/index.jsp)으로 제출 (Due by 10/1)

class, inheritance, interface, enum

Object-Oriented Programming (OOP)

Object − objects have states and behaviors.
Class – defines the grouping of data and code, the “type” of an object
Instance – a specific allocation of a class
Message – sent to objects to make them act
Method – a “function” that an object knows how to perform
Local Variables − variables defined inside methods, constructors or blocks
Instance Variables – variables within a class but outside any method (a specific piece of data belonging to an object)
Class Variables − variables declared within a class, outside any method, with the static keyword
Encapsulation – keep implementation private and seperate from interface
Polymorphism – different objects, same interface
Inheritance – hierarchical organization, share code, customize or extend behaviors