Lernen am Samstag

This commit is contained in:
2019-11-16 16:44:25 +01:00
parent 17e4bc97f2
commit 74050c93b5
7 changed files with 375 additions and 9 deletions

View File

@@ -2,6 +2,8 @@ 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;
/**
@@ -11,28 +13,120 @@ 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 WorkingClass extends AbstractClass implements AnInterface {
class InterfaceImplementer extends AbstractClass implements SuperInterface1, SuperInterface2{
public void methode (int ...name ) {
// methode2(1,3,4); // Geht nicht, muss Array sein
}
public void methode2 (int[] name) {
methode(1, 2, 3);
int [] ints = {1,2,3};
methode(ints);
}
@Test
public void testSomething() {
SuperInterface1.bothStatic();
this.bothAbstract();
SuperInterface1.super.singleDefault();
this.singleDefault();
}
@Override
public void method1() throws AccessDeniedException {
public void bothAbstract() {
}
public void bothDefault() {
SuperInterface1.super.bothDefault();
}
public void oneStaticOneAbstract() {
}
}
abstract class AbstractClass implements AnInterface {
class AnotherImplementer implements SuperInterface1 {
@Override
public abstract void method1() throws AccessDeniedException;
}
public void bothAbstract() {
interface AnInterface {
default void method1() throws IOException {
}
@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();
}
}