YogenGhodke
6/21/2019 - 4:29 AM

Abstract Class

A class whose objects cannot be created, but it can act as base class for inheritance.

Difference between Abstract Class and Interface is that Interface cannot have constructors.

Objects defined with Interface can only call Functions inside the interface.

abstract class abc()
{
    abstract val pqr: String
}

class xyz : abc(), FishAction
{
    override val pqr = "something"
    override fun eat()
        {
            print ("using interface")
        }
}

interface FishAction()
{
    fun eat()    
}


main()
{
 // Objects passed through anyname will only be able to access Interface Functions.
    fun onlyaccessinterface(anyname: FishAction)       
        {
            anyname.eat()
        }
}