0% found this document useful (0 votes)
4 views2 pages

Interfaces 2

The document discusses the relationships between interfaces and classes in programming. It highlights that a class can implement multiple interfaces and extend a class simultaneously, while interfaces can also extend other interfaces. Additionally, it notes that an interface cannot inherit from a class.

Uploaded by

lohithapendli147
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views2 pages

Interfaces 2

The document discusses the relationships between interfaces and classes in programming. It highlights that a class can implement multiple interfaces and extend a class simultaneously, while interfaces can also extend other interfaces. Additionally, it notes that an interface cannot inherit from a class.

Uploaded by

lohithapendli147
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 2

interface A {

void methodA();
}

interface B {
void methodB();
}

class C implements A, B {
public void methodA() {
System.out.println("Method A implementation");
}

public void methodB() {


System.out.println("Method B implementation");
}

class D {
void methodD() {
System.out.println("Method D from class D");
}
}

class C extends D implements A, B {


public void methodA() {
System.out.println("Method A implementation");
}

public void methodB() {


System.out.println("Method B implementation");
}

interface A {
void methodA();
int number();
}

interface B extends A {
void methodB();
}

class C implements B {
public void methodA() {
System.out.println("Method A from interface A");
}

public void methodB() {


System.out.println("Method B from interface B");
}
}

Summary:
-An interface cannot inherit from a class.
-A class can implement multiple interfaces.
-A class can extend a class and at the same time
implement one or more interfaces.
-Interfaces can extend other interfaces.

You might also like