Interfaces Initialisierung
This commit is contained in:
66
src/org/eidecker/oca8lernen/general/Interfaces.java
Normal file
66
src/org/eidecker/oca8lernen/general/Interfaces.java
Normal file
@@ -0,0 +1,66 @@
|
|||||||
|
package org.eidecker.oca8lernen.general;
|
||||||
|
|
||||||
|
import com.sun.xml.internal.ws.policy.privateutil.PolicyUtils;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.nio.file.AccessDeniedException;
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
class TestInterfaces {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testMe() {
|
||||||
|
I1 i1 = new Interfaces();
|
||||||
|
i1.method1();
|
||||||
|
// i1.method2();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public class Interfaces extends AbstractClass implements I1 {
|
||||||
|
|
||||||
|
public void method1() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void method2() throws IOException {
|
||||||
|
I1.method3();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
abstract class AbstractClass {
|
||||||
|
|
||||||
|
public abstract void method1() throws IOException;
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
abstract interface I1 {
|
||||||
|
|
||||||
|
int i = 1;
|
||||||
|
|
||||||
|
static void initialize() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
static void method3() {
|
||||||
|
System.out.println("Hallo aus I1");
|
||||||
|
}
|
||||||
|
|
||||||
|
void method1();
|
||||||
|
|
||||||
|
|
||||||
|
void method2() throws IOException;
|
||||||
|
|
||||||
|
public abstract interface I2 extends I1 {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@@ -0,0 +1,76 @@
|
|||||||
|
package org.eidecker.oca8lernen.general;
|
||||||
|
|
||||||
|
import org.junit.jupiter.api.Test;
|
||||||
|
|
||||||
|
public class KLassenInitialisierung {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testInitialisierung() {
|
||||||
|
System.out.println("Unter\n=====");
|
||||||
|
Oberklasse unter = new Unterklasse();
|
||||||
|
System.out.println("Ober\n=====");
|
||||||
|
Oberklasse ober = new Oberklasse();
|
||||||
|
System.out.println("EchteUnter\n=====");
|
||||||
|
Unterklasse echteUnter = new Unterklasse();
|
||||||
|
|
||||||
|
System.out.println("Zweiter Durchlauf\n=====");
|
||||||
|
System.out.println("Ober\n=====");
|
||||||
|
Oberklasse ober2 = new Oberklasse();
|
||||||
|
System.out.println("Unter\n=====");
|
||||||
|
Oberklasse unter2 = new Unterklasse();
|
||||||
|
System.out.println("EchteUnter\n=====");
|
||||||
|
Unterklasse echteUnter2 = new Unterklasse();
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class Oberklasse {
|
||||||
|
|
||||||
|
static {
|
||||||
|
System.out.println("Oberklasse statischer Initialisierungsblock");
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
System.out.println("Oberklasse Initialisierungsblock");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
System.out.println("Oberklasse Initialisierungsblock 2");
|
||||||
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
System.out.println("Oberklasse statischer Initialisierungsblock 2");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public Oberklasse() {
|
||||||
|
System.out.println("Oberklasse Konstruktor");
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
class Unterklasse extends Oberklasse {
|
||||||
|
|
||||||
|
static {
|
||||||
|
System.out.println("Unterklasse statischer Initialisierungsblock");
|
||||||
|
}
|
||||||
|
|
||||||
|
{
|
||||||
|
System.out.println("Unterklasse Initialisierungsblock");
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
{
|
||||||
|
System.out.println("Unterklasse Initialisierungsblock 2");
|
||||||
|
}
|
||||||
|
|
||||||
|
static {
|
||||||
|
System.out.println("Unterklasse statischer Initialisierungsblock 2");
|
||||||
|
}
|
||||||
|
|
||||||
|
public Unterklasse() {
|
||||||
|
System.out.println("Unterklasse Konstruktor");
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user