Can Abstract Class have constructors?

Can Abstract Class have constructors?

1. Abstract class can have a constructor. But as we can't instantiate abstract class, we can't access it through the object.

2. To access the constructor create a sub class and extend the abstract class which is having the constructor.

Example
public abstract class clsAbstract
{
   public clsAbstract()
   {
       System.out.println(”In clsAbstract()”);
   }
}

public class Test extends clsAbstract
{
   public static void main(String args[])
   {
       Test o1=new Test();
   }
}
How Java addresses the issue of portability and security
Addressing Portability: Many computers of different types with several operating systems are connected to network / internet...
Different data types for integers and floating-point values - Java
The integer and floating-point types are different in terms of the consumption of the bits which represent them...
What is endianness? - Java
Endianness is the process of ordering the addressable sub units such as words, bytes or bits in a longer word that is to store in an external memory...
Post your comment