-
more flexible and reusable
-
Encapsulation--> hiding the data , accessing the data using only method
-
Abstraction--> Hiding the implementation
-
Without perform upcast if we try to downcast , ClassCastException will be thrown.
It is a runtime exception or unchecked exception. It is class, present in java.lang package. It can be avoided by using a operator known as ‘instanceof’.
-
Child ---(extends)--->Parent Parent p=new Child(); //auto downcasting Child c=new (Child)p;//Explicit upcasting
-
Data types int i= short// valid, no truncation int i = long //there will be truncation //error int i =(int)long;//explicit casting
-
BigDecimal bdl=new BigDecimal("22.55688");