Can a abstract class be defined without any abstract methods?

Ads

 
 

Share on Google+Share on Google+

Java Coder
Can a abstract class be defined without any abstract methods?
2 Answer(s)      4 years and 7 months ago
Posted in : Java Beginners

hi,

Can a abstract class be defined without any abstract methods?

thanks,

Ads
View Answers

April 15, 2013 at 10:26 AM


Hi friend,

Yes, we can create an abstract class without declaring any abstract methods.

Following code snippet shows how you can create an abstract class without any abstract methods.

public abstract class AbstractClass
{

    public String getName()
     {
            return "RoseIndia";
     }
}

public class Test extends AbstractClass
{

   public static void main(String args[])
    {
         Test test = new Test();
          String name = test.getName();
          System.out.println("\n"+name);
    }
}


April 15, 2013 at 11:28 AM


Hi,

Yes, you can create abstract class without any abstract methods. Doing so, there is no need to create an instance of the class and we can access its methods.


Ads









Ads

 
Advertisement null

Ads