abstract class A
{
    abstract void callme();
    void callmetoo()
    {
        System.out.println("this is concrete method");
    }
}
class B extends A
{
   void callme()
    {
        System.out.println("implementation of callme");
    }

}
public class abstractdemo {
     public static void main(String []args)
     {
         B b=new B();
         b.callme();
         b.callmetoo();
     }

}

Edited 3 Years Ago by pritaeas: Fixed formatting

They're a tool to allow giving a class you define a type.

yeah sure they are tool

but we can do all those things w/o using abstrat class also

isn't it...?

can u please explain it

i mean interface can also do same thing (exactly)

so whats the difference b/w interface and abstract classes??

No an interface doesn't contain code. An abstract class can have real methods that do something.

okk..
the methods inside abstract classes are called "concrete methods"
isnt it

well why are they named so???

Well, here's a quick answer for the difference b/w abstract classes and interfaces :

Abstract classes can contain both abstract as well as non-abstract(concrete) methods.

Interfaces can only contain abstract methods. NO non-abstract (concrete) methods are allowed inside an interface. In other words, interfaces are 100% abstract classes.

Hope this helps as a starter, for the main course, off course you need a tutor or at least a good book. For the latter you can consult "head first JAVA" by Kathy Sierra and Bert Bates. Its an excellent book to learn java.

Good luck and happy learning :)

Edited 6 Years Ago by NP-complete: n/a

This article has been dead for over six months. Start a new discussion instead.