What is the use of main method in abstract class?

后端 未结 4 830
攒了一身酷
攒了一身酷 2021-02-05 10:00

I know that we can write main method in abstract class, but what we can achieve from it ?

 public abstract class Sample
 {
         public static void main(Strin         


        
4条回答
  •  不思量自难忘°
    2021-02-05 10:31

    public abstract class Abstrc
    {
        Abstrc(){} // constructor
        public abstract void run(); // abstract method
        public static int mul(){return 3*2;} // static method
        public static void main(String[] args) 
        { // Static method that can be accessed without instantiation 
             System.out.println("Your abstract no is : " + Abstrc.mul());
        }
    }
    

    Your abstract no is : 6

提交回复
热议问题