You need to sign in to do that
Don't have an account?
sekhar raj 4
Abstract class cannot be constructed
public abstract class cellshop
{
public cellshop()
{
system.debug('jjjjjj');
}
private abstract void cost();
void change()
{system.debug('iiiii');}
class ab extends cellshop
{
private override void cost()
{system.debug('cell cost7872');
}
}
}
{
public cellshop()
{
system.debug('jjjjjj');
}
private abstract void cost();
void change()
{system.debug('iiiii');}
class ab extends cellshop
{
private override void cost()
{system.debug('cell cost7872');
}
}
}
To summarize,
- Abstract classes contain abstract method (signatures) which are not implemented. Abstract classes themselves cannot be constructed, but must be extended by a subclass for constructing an instance thereof.
- Virtual classes are very similar to abstract classes, but you can implement the methods, construct virtual classes, but at the same time override methods in the virtual class using extends and sub classes.
If you're interested here's another article on how you can utilize abstract classes and interfaces together: