Abstract type: Difference between revisions

m (→‎Abstract type: Typo fixed)
Line 38:
 
=={{header|Java}}==
AbstractMethods classesthat don't have an implementation are called abstract methods in Java. canA defineclass methodsthat andcontains aren'tan requiredabstract method or inherits one but did not override it must be an abstract class; but an abstract class does not need to havecontain any abstract methods. An abstract class cannot be instantiated. If a method is abstract, it must be public or protected
<java>public abstract class Abs {
abstract public int method1(double value);
Line 46:
}
}</java>
Interfaces in Java may not defineimplement any methods and all methods mustare beimplicitly public and can be abstract.
<java>public interface Inter {
public int method1(double value);
public int method2(String name);
abstract public int add(int a, int b);
}</java>
 
Anonymous user