0% found this document useful (0 votes)
6 views

Data Abstraction

Uploaded by

mitianrocks
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
6 views

Data Abstraction

Uploaded by

mitianrocks
Copyright
© © All Rights Reserved
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 1

Java abstract class is a class that can not be initiated by itself, it needs to be

subclassed by another class to use its properties. An abstract class is declared


using the “abstract” keyword in its class definition.

In Java, the following some important observations about abstract classes are as
follows:

1. An instance of an abstract class can not be created.


2 Constructors are allowed.
3. We can have an abstract class without any abstract method.
4. There can be a final method in abstract class but any abstract method in
class(abstract class) can not be declared as final or in simpler terms final
method can not be abstract itself as it will yield an error: “Illegal combination
of modifiers: abstract and final”
5. We can define static methods in an abstract class
6. We can use the abstract keyword for declaring top-level classes (Outer class) as
well as inner classes as abstract
7. If a class contains at least one abstract method then compulsory should declare
a class as abstract
8. If the Child class is unable to provide implementation to all abstract methods
of the Parent class then we should declare that Child class as abstract so that the
next level Child class should provide implementation to the remaining abstract
method

Properties of Abstract class:-

1.In Java, just like in C++ an instance of an abstract class cannot be created, we
can have references to abstract class type though. It is as shown below via the
clean Java program.

2. Like C++, an abstract class can contain constructors in Java. And a constructor
of an abstract class is called when an instance of an inherited class is created.
It is as shown in the program below as follows:

3. In Java, we can have an abstract class without any abstract method. This allows
us to create classes that cannot be instantiated but can only be inherited. It is
as shown below as follows with help of a clean java program.

4. Abstract classes can also have final methods (methods that cannot be overridden.

5. For any abstract java class we are not allowed to create an object i.e., for an
abstract class instantiation is not possible.

6. Similar to the interface we can define static methods in an abstract class that
can be called independently without an object.

7. We can use the abstract keyword for declaring top-level classes (Outer class) as
well as inner classes as abstract

8. If a class contains at least one abstract method then compulsory that we should
declare the class as abstract otherwise we will get a compile-time error

You might also like