Why can't an object of abstract class be created?

前端 未结 16 979
误落风尘
误落风尘 2020-12-02 21:25

Here is a scenario in my mind and I have googled, Binged it a lot but got the answer like

\"Abstract class has not implemented method so, we cant create the object\

16条回答
  •  醉话见心
    2020-12-02 21:43

    we can create object for abstract class like this also...

    public class HelloWorld
    {
        public static void main(String args[])
        {
            Person p = new Person()
            { 
                void eat()
                {
                    console.writeline("sooper..");
                } 
            }; 
            p.eat();
        }
    }
    abstract class Person
    { 
        abstract void eat(); 
    } 
    

提交回复
热议问题