jina
3
Q:

geeks for geeks java interfaces

// Assume we have the simple interface:
interface Appendable {
	void append(string content);
}
// We can implement it like that:
class SimplePrinter implements Appendable {
 	public void append(string content) {
   		System.out.println(content); 
    }
}
// ... and maybe like that:
class FileWriter implements Appendable {
 	public void append(string content) {
   		// Appends content into a file 
    }
}
// Both classes are Appendable.
3
// Assume we have the simple interface:
interface Appendable {
	void append(string content);
}
// We can implement it like that:
class SimplePrinter implements Appendable {
 	public void append(string content) {
   		System.out.println(content); 
    }
}
// ... and maybe like that:
class FileWriter implements Appendable {
 	public void append(string content) {
   		// Appends content into a file 
    }
}
// Both classes are Appendable.
0
how to implement a interface in java
0
// Java program to demonstrate working of  
// interface. 
import java.io.*; 
  
// A simple interface 
interface In1 
{ 
    // public, static and final 
    final int a = 10; 
  
    // public and abstract  
    void display(); 
} 
  
// A class that implements the interface. 
class TestClass implements In1 
{ 
    // Implementing the capabilities of 
    // interface. 
    public void display() 
    { 
        System.out.println("Geek"); 
    } 
  
    // Driver Code 
    public static void main (String[] args) 
    { 
        TestClass t = new TestClass(); 
        t.display(); 
        System.out.println(a); 
    } 
} 
0

New to Communities?

Join the community