Skip to main content

Posts

Showing posts from November, 2015

Abstract Class In Java

An abstract class is a class which cannot be instantiated. An abstract class is used by creating an inheriting subclass that  can  be instantiated. An abstract class does a few things for the inheriting subclass: Define methods which can be used by the inheriting subclass. Define abstract methods which the inheriting subclass must implement. Provide a common interface which allows the subclass to be interchanged with all other subclasses. Here's an example: package com . codetalk . abstractclass ; /** * @author Rakesh KR * */ abstract public class AbstractClass { abstract public void abstractMethod (); public void implementedMethod (){ System . out . println ( "Implemented Method" ); } final void finalMethod (){ System . out . println ( "Final Method" ); } } Here's a correct  ImplementingClass package com . codetalk . abstractclass ; /** * @author Rakesh KR * */ public