Can a abstract class be defined without any abstract methods?

Can a abstract class be defined without any abstract methods?

hi,

Can a abstract class be defined without any abstract methods?

thanks,

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









Related Tutorials/Questions & Answers:
Can a abstract class be defined without any abstract methods?
Abstract Class in Java
Advertisements
Abstract class
Can a abstract class be declared final?
Abstract class
abstract class
Java Abstract Class
Abstract class
abstract class
Abstract class
Can you create an object of an abstract class?
abstract class
Can we instantiate abstract class in Java?
Abstract class,Abstract methods and classes
Using Abstract Class
Java Abstract Class Example
code for abstract class
variables and methods declared in abstract class is abstract or not
Why Abstract Class?
Why Abstract Class?
Abstract class and interface in Java
Interface and Abstract class
Interface vs abstract class
Write Full concept of abstract class
Explain final class, abstract class and super class.
What is an Abstract Class and what is it's purpose?
Difference between abstract class and an interface
How to Declare Abstract Class in PHP ?
overriding in derived class from abstract class
abstract method
why we use abstract class in java?

Ads