136 lines
2.2 KiB
Java
136 lines
2.2 KiB
Java
package org.eidecker.oca8lernen.general;
|
|
|
|
import java.io.IOException;
|
|
import java.nio.file.AccessDeniedException;
|
|
import java.util.zip.DataFormatException;
|
|
|
|
import org.junit.jupiter.api.Test;
|
|
|
|
/**
|
|
* @author seidecke.
|
|
*/
|
|
public class DoubleImplementsClash {
|
|
|
|
@Test
|
|
public void testSomeTHings() {
|
|
InterfaceImplementer implementer = new InterfaceImplementer();
|
|
// implementer.bothStatic() // Nicht vorhanden, nur im Interface
|
|
implementer.bothDefault();
|
|
implementer.singleDefault();
|
|
implementer.abstractClassAndInterfaceDefault();
|
|
}
|
|
|
|
}
|
|
|
|
class InterfaceImplementer extends AbstractClass implements SuperInterface1, SuperInterface2{
|
|
|
|
|
|
public void methode (int ...name ) {
|
|
// methode2(1,3,4); // Geht nicht, muss Array sein
|
|
methode2(name);
|
|
}
|
|
|
|
public void methode2 (int[] name) {
|
|
methode(1, 2, 3);
|
|
int [] ints = {1,2,3};
|
|
methode(ints);
|
|
|
|
System.out.println(new StringBuilder("Hallo").toString());
|
|
}
|
|
|
|
@Test
|
|
public void testSomething() {
|
|
SuperInterface1.bothStatic();
|
|
this.bothAbstract();
|
|
SuperInterface1.super.singleDefault();
|
|
this.singleDefault();
|
|
}
|
|
|
|
@Override
|
|
public void bothAbstract() {
|
|
|
|
}
|
|
|
|
public void bothDefault() {
|
|
SuperInterface1.super.bothDefault();
|
|
|
|
|
|
}
|
|
|
|
public void oneStaticOneAbstract() {
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
class AnotherImplementer implements SuperInterface1 {
|
|
|
|
@Override
|
|
public void bothAbstract() {
|
|
|
|
}
|
|
|
|
@Override
|
|
public void oneStaticOneAbstract() {
|
|
|
|
}
|
|
}
|
|
|
|
interface SuperInterface1 {
|
|
static void bothStatic() {
|
|
}
|
|
|
|
default void bothDefault() {
|
|
}
|
|
|
|
default void singleDefault() {
|
|
|
|
}
|
|
|
|
void bothAbstract();
|
|
|
|
void oneStaticOneAbstract();
|
|
}
|
|
|
|
interface SuperInterface2 {
|
|
|
|
static void bothStatic() {
|
|
}
|
|
|
|
default void bothDefault() {
|
|
}
|
|
|
|
void bothAbstract();
|
|
|
|
static void oneStaticOneAbstract() {
|
|
|
|
}
|
|
|
|
default void abstractClassAndInterfaceDefault() {
|
|
System.out.println("SuperInterface2 abstractClassAndInterfaceDefault");
|
|
"Halli".length();
|
|
}
|
|
}
|
|
|
|
abstract class AbstractClass {
|
|
|
|
|
|
public void abstractClassAndInterfaceDefault() {
|
|
System.out.println("AbstractClass abstractClassAndInterfaceDefault");
|
|
}
|
|
|
|
public void throwsException() throws IOException {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
class ErbendeKlasse extends AbstractClass {
|
|
|
|
@Override
|
|
public void throwsException() throws AccessDeniedException {
|
|
new ErbendeKlasse();
|
|
}
|
|
}
|