Back to Top

Sunday, 11 August 2013

JAVA: Keyword: abstract


     This is used to define a class or a method as an abstract operation. When a method is declared as abstract, that means, the method where it is declared (within the class) have no body of the method rather the method can be overridden, through inheritance and define it's body.
     When a class  contains any abstract method, it must be declared as abstract.
An abstract class cannot be final.
An abstract method cannot be finalstatic nor native.


abstract class SampleAbstractClass {
    * Sample abstract class.
    * @author
      // Sample abstract method.
      public abstract void sampleabstractmethod() ;
      public void sampleNormalMethod(){


public class TestAbstractClass{
    * Sample class to call SampleAbstractClass.
    * @author
      public static void main(String[] args) {
            SampleAbstractClass objSampleAbstractClass = newSampleAbstractClass() {
                  public void sampleabstractmethod() {
                                    .println("TestAbstractClass.main(...).new SampleAbstractClass() {...}.sampleabstractmethod()");


TestAbstractClass.main(...).new SampleAbstractClass() {...}.sampleabstractmethod()

4 Responses to “ JAVA: Keyword: abstract ”

Anonymous said...
1 September 2013 at 15:20

When a class is declared as an abstract, the class should have at least one abstract method.
I think this statement is WRONG..

leona fassi said...
6 September 2014 at 21:27

I like it thanks for sharing such a brilliant information, great blog

Picgrant Singapore 2014

Naviya Nair said...
24 October 2016 at 15:02

I have read your blog its very attractive and impressive. I like it your blog.

Java Training in Chennai Java Training in Chennai | Core Java Training in Chennai

Online Java Training Java 8 Online Training | Java J2EE Online Training | JavaEE Training Institute in Chennai Java Training Institutes

Java Training Institutes in Chennai Java Training in Chennai

sumant kumar said...
29 August 2018 at 18:41

I found best article.thank you for sharing useful info.
web programming tutorial

Post a Comment

Popular Posts

All Rights Reserved JAVA INTERVIEW QUESTIONS | Privacy Policy | Anijit Sarkar
blog links Web Directory Academics Blogs