• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

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.
 
Your mother was a hamster and your father was a tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic