'Back-End'에 해당되는 글 135건

donaricano-btn

 Runtime Polymorphism


1. Polymorphism

1) compile time polymorphism

- You overload static method in java

2) runtime polymorphism


2. Runtime Polymorphism(Dynamic Method Dispatch)

- Process in which a call to an overridden method is resolved at runtime rather than compile-time

- an overridden method is called through the reference variable of a superclass


3. Upcasting

- When reference variable of Parent class refers to the object of Child class, It is known as upcasting



4. Runtime Polymorphism example

 

- 8,9


5. Runtime Polymorphism with data member

- Runtime polymorphism can't be achieved by data members

 

- 0 

'Back-End > Java_1' 카테고리의 다른 글

[Java] Instanceof  (0) 2016.09.09
[Java] Static Binding and Dynamic Binding  (0) 2016.09.08
[Java] Final keyword  (0) 2016.09.07
[Java] Instance initializer block  (0) 2016.09.07
[Java] Super keyword  (0) 2016.08.25
블로그 이미지

리딩리드

,
donaricano-btn

 Final keyword

- It in java is used to restrict the user

- Stop Value Change

- Stop Method Overridding

- Stop Inheritance


1. How to use

- final keyword can be applied with the variables, a final variable that have no value it is called blank final variable or uninitialized final variable

- blank final variable

a. It can be initialized in the constructor only

b. It can be static also which will be initialized in the static block only


2. Final variable


Complile time error

Final variable once assigned a value can never be changed


3. Final method

 

Complile time error

- It cannot override it


4. Final class

 

Complile time error

- You cannot extend it


5. Question

1) Is final method inherited?

- final method is inherited but you cannot override

2) What is blank or uninitialized final variable?

- A final variable that is not initialized at the time of declaration is known as blank final variable

- It can be initialized only in constructor

 

3) static blank final variable

- A static final variable that is not initialized at the time of declaration is known as static blank final variable

- It can be initialized only in static block

 

4) What is final parameter?

- You cannot change the value of final it

 

Complile time error

5) Can we declare a constructor final?

- No, because is never inherited



'Back-End > Java_1' 카테고리의 다른 글

[Java] Static Binding and Dynamic Binding  (0) 2016.09.08
[Java] Runtime Polymorphism  (0) 2016.09.08
[Java] Instance initializer block  (0) 2016.09.07
[Java] Super keyword  (0) 2016.08.25
[Java] Covariant Return type  (0) 2016.08.24
블로그 이미지

리딩리드

,
donaricano-btn

 Instance initializer block


- It used to initialize the instance data member

- It run each time when object of the class is created

- The initialization of the instance variable can be directly but there can be performed extra operations while initializing the instance variable it the instance initializer block


1. Why use instance initializer block?

- Suppose I have to perform some operations while assigning value to instance data member


2. Example


3. What is invoked first, instance initializer block or constructor?

1) How to work

- It seems that instance initializer block is firstly invoked but NO

- The java compiler copies the instance initializer block in the constructor after the first statement super()

- constructor is invoked firstly

4. Rules for instance initiallizer block

1) The instance initializer block is created when instance of the class is created

2) It is invoked after the parent class constructor is invoked

3) It comes in the order in which they appear


'Back-End > Java_1' 카테고리의 다른 글

[Java] Runtime Polymorphism  (0) 2016.09.08
[Java] Final keyword  (0) 2016.09.07
[Java] Super keyword  (0) 2016.08.25
[Java] Covariant Return type  (0) 2016.08.24
[Java] Overloading vs Overriding  (0) 2016.08.24
블로그 이미지

리딩리드

,
donaricano-btn

단순 하이버네이트 예제


- 하이버네이트만을 이용하면 세션의 열기/ 닫기와 예외처리를 개발자가 기술해야 하기 때문에 소스가 길어짐

- 트랜잭션은 명시적 트랜잭션이됨

- 비즈니스 로직층과 데이터 액세스 층의 강한 연결


1. 폴더구성

2. pom.xml


- 오라클 사용

3. hibernate.cfg.xml

 

4. Person.hbm.xml

 

5. NumDao.java

 

https://github.com/KyleJeong/Hibernate
블로그 이미지

리딩리드

,