Class4
Class4
abstract classes
It is used only for classes and methods and not for data variables
- Abstract classes cannot be instantiated
- Abstract methods do not have a body - meaning, there is no implementation in the
abstract method, derived classes will have to implement the abstract method
- Abstract classes can have both abstract and concrete methods, concrete method has
an implementation defined
- Abstract classes can have constructors
- Abstract classes can contain instance variables
- Abstract classes can implement interfaces
- Any class that contains one or more abstract methods must also be declared
abstract
- The following are various illegal combinations of other modifiers for methods
with respect to abstract modifiers:
final
abstract native
abstract synchronized
abstract static
abstract private
abstract strict
- When we want to use abstract classes, we are forced to provide implementation for
abstract methods in the abstract class
- When we provide implementation in the derived classes, we are essentially
overriding the method from parent class
In Java, data hiding is implemented through getter and setter methods and private
variables
Getter is used to accessing the private data and setter is used to modify the
private data only after authentication
Data Hiding is hiding internal data from outside users. The internal data should
not go directly that is outside person/classes is not able to access internal data
directly. It is achieved by using an access specifier- a private modifier.