Androidberry logo Androidberry text logo
AndroidBerry Home
  • Learn Java
  • Java Programs
  • Interview Questions
  • Androidberry facebook
  • Androidberry twitter
  • Androidberry google plus

Java Tutorials


Basic Introduction

Decision Making

Looping

Classes and Objects

Java Class
Java Object
Java Object Array
Java Nesting of Classes
Java Methods
Java Method Overloading
Java Constructor
Java Constructor Overloading
Java This Keyword
Java Garbage Collection
Java Static Keyword
Java Arrays
Java String
Java StringBuffer
Java String vs StringBuffer
Java Vector Class
Java Vector vs Array
Java Wrapper Classes

Inheritance

Java Inheritance
Java Single Inheritance
Java Super Keyword
Java Multiple Inheritance
Java Hierarchical Inheritance
Java Multilevel Inheritance
Java Method Overriding
Java Abstract Classes,Methods
Java Final Variables, Methods
Java Dynamic Dispatch Methods
Java Visibility Controls

Interfaces

Java Interface
Java Class vs Interface
Java Multiple Inheritance
Java Nested Interface

Packages

Java Packages
Java Built in packages
Java Package Access Specifiers

Exception Handling

Multithreading

Java Applets

Graphics Programming

More on Java

Java Programs
Java Keywords Dictionary
Java Interview Questions

Abstract Methods and Classes


Method Overriding

In java method cannot be redefined in a subclass by making it as final. But the abstract concept is opposite to final.

Abstract can be indicated that a method must always be redefined in a subclass.

The keyword abstract is used for making methods and classes abstract.

Abstract Class

The class which is declared using keyword abstract called as abstract class.

Properties of abstract Class

  • When the class is declared as abstract then methods can be declared as abstract.
  • It is not neccessary in class that all methods should be abstract.
  • When abstract class contains abstract methods then class must be inherited by child class to write the body of the abstract methods.

Abstract Methods

The methods which are declared as abstract called as abstract methods.

Properties of abstract methods

  • They are always declared in the parent class.
  • All methods which are declared as abstract must be always redefined in all the child classes.
  • The class must be abstract in order to declare abstract methods.
  • Abstract methods are always declared in the parent class without writting it's body.
  • We can declare abstract methods in the subclass too.

Abstract class and method Syntax

abstract class className // abstract class declaration
{                        
    abstract type methodName(); // abstract method declaration
}

Example

Program to demonstrate abstract class and method.

abstract class Software
{
    String name;
    abstract void features();
}

Output

I'm display 1
I'm display 2
<< Previous Next >>

See Also

All Java Programs
Java Keywords
Java Interview Questions

AndroidBerry Support

About us
Contact us
Suggest us
Questions?

Follow us

Androidberry FacebookFacebook
Androidberry TwitterTwitter
Androidberry GooglePlusGoogle+
Back to top
Androidberry Name Logo