0
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 by pritaeas: Fixed formatting

3
Contributors
11
Replies
12
Views
7 Years
Discussion Span
Last Post by NP-complete
0

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...?

0

can u please explain it

i mean interface can also do same thing (exactly)

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

0

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

0

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

well why are they named so???

0

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 by NP-complete: n/a

This topic has been dead for over six months. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.