Benefits of using an abstract classes vs. regular class

后端 未结 9 904
独厮守ぢ
独厮守ぢ 2021-01-31 17:52

I have decided to start doing small coding projects on my own that focus on code quality instead of code quantity and have a question about the use of abstract classes.

9条回答
  •  被撕碎了的回忆
    2021-01-31 18:23

    in my opinion abstract classes have more use in real projects as on books. some times project managers just provide the methods declaration and you have to write code for the methods without modify the core syntax provided by manager. so that is how an abstract class is use full. in simple class method define,declared and coded in same time but not in abstract classes. for ex:-

    abstract class Test
    {
        abstract void show();//method provided
    }
    class Child extends Test
    {
        void show()//coding 
        {
            System.out.println("saurav");
        }
    }
    class main
    {
        public static void main(String[] args) 
        {
        Test c = new Child();
        c.show();   
        }
    }
    

提交回复
热议问题