Professional Documents
Culture Documents
}
class Pig implements Animal
{
myPig.animalSound();
myPig.sleep();
}
Output:
Code:
interface FirstInterface {
public void myMethod(); // interface method
}
interface SecondInterface {
public void myOtherMethod(); // interface method
}
class DemoClass implements FirstInterface, SecondInterface {
public void myMethod() {
System.out.println("myMethod Says: "+"Some text..");
}
public void myOtherMethod() {
System.out.println("myOtherMethod Says: "+"Some other text...");
}
}
class Main2 {
public static void main(String[] args) {
DemoClass myObj = new DemoClass();
myObj.myMethod();
myObj.myOtherMethod();
}
}
Output:
Code:
import java.util.Scanner;
interface Customer{
void input();
void output();
}
import java.util.Scanner;
class Service implements Customer {
String name;
double salary;
}
}
class Main2{
}
}
Output: