• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

doubt regarding same method in interface and abstract class

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
abstract class a
{
public void abstract fun();
}
interface B
{
void fun();
}
public class c extend a implements B
{
public static void main(String arg[])
{
how to call abstract method of class
and interface.
}
}
clarify my doubt with syntax
 
Bartender
Posts: 6663
5
MyEclipse IDE Firefox Browser Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

how to call abstract method of class
and interface.



You cannot call abstract methods. Implement the method and then make a call to it
 
Greenhorn
Posts: 11
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by naresh dharami vatsal:
abstract class a
{
public void abstract fun();
}
interface B
{
void fun();
}
public class c extend a implements B
{
public static void main(String arg[])
{
how to call abstract method of class
and interface.
}
}
clarify my doubt with syntax

 
Ranch Hand
Posts: 278
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
If you observe,does it matter which method will be called ,since no method ,no fun() is having implementation.
Because of no- body in both Abrstract class or interface ,we cant call with their methods without implementor-class-object.

When implemented in some class,
class x extends a implements b
{
public void fun() //this methd comes from a or b,doesnt matter,its template only with same signature in both
{ ...implementation ..code ...


}

when you call ,objectofx.fun() ,now belongs to class x- instance.
you cant say a.fun() or b.x(); since they have no implementation.
 
Consider Paul's rocket mass heater.
reply
    Bookmark Topic Watch Topic
  • New Topic