'Back-End/Java_1'에 해당되는 글 48건

[Java] Package

Back-End/Java_1 2016. 9. 12. 14:48
donaricano-btn

 Package

- Package is a group of similar types of classes, interface and sub-packages

- built-in package(java, lang, awt, javax...) and user-defined package


1. Advantage of Java Package

- Java package is used to categorize the classes and interface so that they can be easily maintained

- It provides access protection

- It removes naming collision

2. How to compile and run java package

1) compile


2) run

 


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

[Java] Call by value  (0) 2016.09.13
[Java] Encapsulation  (0) 2016.09.12
[Java] Interface  (0) 2016.09.12
[Java] Abstract class  (0) 2016.09.12
[Java] Instanceof  (0) 2016.09.09
블로그 이미지

리딩리드

,

[Java] Interface

Back-End/Java_1 2016. 9. 12. 14:00
donaricano-btn

Interface

interface is a blueprint of a class

- It has static constants and abstract methods only

- It is used to achieve fully abstraction and multiple inheritance in java


1. Why use it

- It is used to achieve fully abstraction

- By interface, we can support the functionality of multiple inheritance

- It can be used to achieve loose coupling

- The java compiler adds public and abstract keywords before the interface method and public, static and final keywords before data members

2. Example


3. Multiple inheritance 

 

1) Is it possible by interface, why?

- There is no ambiguity as implementation is provided by the implementation class

4. What is marker or tagged interface?

- An interface that have no member is known as marker or tagged interface

- Serializable, Cloneable, Remote....

- They are used to provide some essential information to the JVM so that JVM may perform some useful operation

 


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

[Java] Encapsulation  (0) 2016.09.12
[Java] Package  (0) 2016.09.12
[Java] Abstract class  (0) 2016.09.12
[Java] Instanceof  (0) 2016.09.09
[Java] Static Binding and Dynamic Binding  (0) 2016.09.08
블로그 이미지

리딩리드

,
donaricano-btn

Abstract class

- A class that is declared with abstract keyword, is known as abstract class

- It can have abstract and non-abstract methods


1. Abstraction in java

- Abstraction is a process of hiding the implementation details 

- It showing only functionality to the user

- Abstraction lets you focus on what the object does instead of how it does it


1) Ways to achieve Abstraction

- Abstract class

- Interface

2. Example

3. Abstract class having constructor, data member, methods

- If there is any abstract method in a class, that class must be abstract

- If you are extending any abstract class that have abstract method, you must either provide the implementation of the method or make this class abstraction



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

[Java] Package  (0) 2016.09.12
[Java] Interface  (0) 2016.09.12
[Java] Instanceof  (0) 2016.09.09
[Java] Static Binding and Dynamic Binding  (0) 2016.09.08
[Java] Runtime Polymorphism  (0) 2016.09.08
블로그 이미지

리딩리드

,
donaricano-btn

 Instanceof

- instanceof operator is used to test whether the object is an instance of the specified type

- It is also known as type comparison operator

It returns either true or false


1. Example


- true

2. instanceof in java with a variable that have null value

 

- false

3. Downcasting with java instanceof operator

1) Downcasting

When subclass type refers to the object of Parent class, it is known as downcasting

 

 

2) Possibility of downcasting with instanceof

 

3) Downcasting without the use of instanceof

 

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

[Java] Interface  (0) 2016.09.12
[Java] Abstract class  (0) 2016.09.12
[Java] Static Binding and Dynamic Binding  (0) 2016.09.08
[Java] Runtime Polymorphism  (0) 2016.09.08
[Java] Final keyword  (0) 2016.09.07
블로그 이미지

리딩리드

,