Abstract type: Difference between revisions
Content added Content deleted
Line 1,422: | Line 1,422: | ||
=={{header|Java}}== |
=={{header|Java}}== |
||
Java has an ''interface'' and an ''abstract class''.<br /> |
Java has an ''interface'' and an ''abstract class''. Neither of which can be instantiated, and require some sort of implementation or abstraction.<br /> |
||
For an ''interface'', only the ''private'' and ''default'' access modifiers are allowed, which also implies they require code.<br /> |
For an ''interface'', only the ''private'' and ''default'' access modifiers are allowed, which also implies they require code.<br /> |
||
A ''private'' method cannot be overridden by a sub-class, and a ''default'' method, optionally, can.<br /> |
A ''private'' method cannot be overridden by a sub-class, and a ''default'' method, optionally, can.<br /> |
||
Line 1,478: | Line 1,478: | ||
Here is an example of a class which ''extends'' an ''abstract class''. |
Here is an example of a class which ''extends'' an ''abstract class''. |
||
<syntaxhighlight lang="java"> |
<syntaxhighlight lang="java"> |
||
class ExampleImpl extends Example { |
|||
public int methodC(int valueA, int valueB) { |
public int methodC(int valueA, int valueB) { |
||
return valueA + valueB; |
return valueA + valueB; |