Answers for "java what are abstract classes"

0

abstract class java constructor

/**
 * Simple Java program to prove that abstract class can have constructor in Java.
 * @author http://java67.blogspot.com
 */
public class AbstractConstructorTest {

    public static void main(String args[]) {
       Server server = new Tomcat("Apache Tomcat");
       server.start();
    }
}

abstract class Server{
    protected final String name;
   
    public Server(String name){
        this.name = name;
    }
   
    public abstract boolean start();
}

class Tomcat extends Server{
   
    public Tomcat(String name){
        super(name);
    }

    @Override
    public boolean start() {
       System.out.println( this.name + " started successfully");
       return true;
    }
   
}

Output:
Apache Tomcat started successfully
Posted by: Guest on May-18-2020
1

abstract classes and interfaces in java

abstract class have no implementation of methods functions inside it. the classes which extending abstract class have to implement it
Posted by: Guest on December-30-2020

Code answers related to "java what are abstract classes"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language