Core Java Tutorials


Introduction

Java Hello World

Java Compilation

JDK New Features

JVM Architecture

Java OOPs Concepts

Java Package

Array

Exception Handling

String

Immutable Class

File Handling

Serialization

MultiThreading

Volatile

Concurrent Package

Collection

Collection Internal

Generics

Cloning

Reflection In Java

Annotation

Class Loader

Java Inner classes

Garbage Collector

JDBC

References In Java

Heap Dump & Thread Dump

Abstract Class In Java

Abstract Class In Java are classes that contain one or more abstract methods. An abstract method is a method that is declared, but contains no implementation. Abstract classes may not be instantiated, and require subclasses to provide implementations for the abstract methods. A class that extends an abstract class must implement all its abstract methods (if any). Otherwise, the sub-class must be declared as abstract as well. Finally, any implementation of an abstract method can be overridden by additional sub-classes.
abstract-class-in-java

How to declaring an Abstract Class in Java

In Java you declare that a class is abstract by adding the abstract keyword to the class declaration. Here is a Java abstract class example

public abstract class MyAbstracts  {
	
	//methods and variables  
}

How to declaring an Abstract method in Java

If a method is declared as abstract then class must be an abstract class.You declare a method abstract by adding the abstract keyword in front of the method declaration. Here is a Java abstract method example

public abstract class MyAbstracts  {
	public abstract void absMethod();
}

Subclasses of an abstract class must implement (override) all abstract methods of its abstract superclass. The non-abstract methods of the superclass are just inherited as they are. They can also be overridden, if needed. here is an example sub class of an abstarct class

abstract class MyAbstracts  {
	public abstract void show();
}
public class MyImpleMentetion extends MyAbstract{
	
	public void show() {
	System.out.println("hello i am declared in MyAbstract class");
}

Output :

hello i am declared in MyAbstract class

Important points for abstract class

abstract keyword is used to create an abstract class in java
Abstract class in java can't be instantiated.
If a class have abstract methods, then the class should also be abstract using abstract      keyword, else it will not compile
It's not necessary to have abstract class to have abstract method.
The subclass of abstract class in java must implement all the abstract methods unless the     subclass is also an abstract class.