정보보안공부
*** n01.generic_impl - Worker -> public class Worker extends Person //Worker클래스에 Person클래스 상속 { public Worker(String name) { super(name); } } *** n01.generic_impl - Person ->public class Person { private String name; public Person(String name) { this.name = name; } public String getName() {return name;} public String toString() {return name;} *** n01.generic_impl - Storage -> public interface St..
*** generic_ex - Apple -> Apple클래스 생성 *** generic_ex - Box -> public class Box { private T t; //원래 int나 Object자리였는데 T로 설정 public T get() { return t; } public set(T t) { this.t = t; } *** generic_ex - BoxExample -> Box b1 = new Box(); -> b1.set("hello"); -> String str = b1.get(); get()은 hello이므로 str에 hello값 대입 -> Box b2 = new Box(); -> b2.set(6); -> int value = b2.get(); get()은 6이므로 value에 6 대입 -..
*** j2.object.sysyem - Employee -> Employee클래스 정의 -> 생성자 public int eno; 선언후 public Employee(int eno) { this.eno = eno; } -> public void finalize(){ System.out.println("Employee(" + eno + ") 이 메모리에서 제거됨."); } System.gc()선언시 finalize()메소드 실행 *** j2.api.System - GcExample -> Employee emp; -> emp = new Employee(1); -> emp = null; -> emp = new Employee(2); -> emp = new Employee(3); -> 생성자에의해 Employe..
*** NumMatch -> input = new Scanner(System.in).nextInt(); nextInt() 입력 데이터를 정수형으로처리, 영어 알파벳입력하는 경우 Exception발생 -> if(input 100) { System.out.print("1부터100사이 정수입력하시오:"); } Exception으로도 표현가능 -> 두가지의 Exception실행 가능 *** NumMatchError1 : 첫번째 Exception실행 -> 첫번째 Exception발생 정수형대신 알파벳 입력하는 경우 예외처리 -> try { input = new Scanner(System.in).nextInt(); 부터 if(input 100 ) { } 까지 try..
*** NullPointerExample -> data = null 일때 System.out.println(data.toString()); 은 오류 발생 -> Exception발생할 수 있는 부분을 블럭처리한다. try { data = null; System.out.println(data.toString()) } catch로 Exception 처리 catch(Exception e) { System.out.println("예외처리 합니다.") } *** ExceptionTest -> (int)(Math.random() * 10) 이 0이나올경우 exception발생 -> Exception발생할 수 있는 부분을 블럭처리한다. try { result = number / (int)(Math.random() * ..
*** Product -> 추상메소드는 추상클래스에서만 정의한다. -> abstract 메소드는 선언만. { } 안한다. *** ProductEx -> abstract클래스는 직접객체를 생성하지 못한다. Product p = new Product(); ->X *** ITest -> interface ITest -> void work(); 컴파일 단계에서 public abstarct가 된다. { }하지않는다. -> default void setOn(); 인스턴스 메소드 선언시 default 필수 -> static void setVersion(); static 메소드 가능 -> 추상메소드 선언 - 기본 *** interfaceEx -> ITest인터페이스를 상속하기위해 implements사용 -> ITest..
***ScopeEx -> ScopeA에서 public int , int , protected , private 4가지변수를 선언한다. -> ScopeAA는 ScopeA를 상속받는다. -> ScopeEx는 ScopeA와 ScopeAA객체를 만들고 aa.method();로 ScopeAA의 method() 를 실행한다. -> System.out.println(a.toString()); 과 System.out.println(a)가 같음을 알수있다. 출력되는값은 메모리의 참조 값이다. *** PolyArgumentTest() -> Product와 Product를 상속받는 Tv, Computer, Audio선언 -> Buyer클래스에 money = 1000; bonusPoint = 0;선언후 메소드 void buy..
*** 프레임 만드는 법 1) 클래스와 함수를 사용하지 않고 만들어보기 -> Button의 이름은 text를 통해 Quit로 하며 버튼을 눌렀을때 작동은 command=quit를 이용해 종료되도록한다. Quit의 색깔은 foreground="red"를 통해 빨간색으로 한다. -> pack()을 이용해 해당버튼을 window라는 큰박스안에 넣어준다. pack을 쓰지 않으면 보이지 않는다. 2) 클래스와 함수를 통해 만들어보기 --> MyFrame클래스가 실행되면 __init__ 함수안에 목록들이 자동실행하는데 createWidget도 함수로 만들어 self.createWidget()에 의해 실행되게한다. --> Button(self, text="Quit", command = quit에 의해 버튼의 이름을 ..