• Extends or Implements :
    • Extend to an external public class
    • Implements to an Interface ( which is public in default)
Code Snippets:


Interface is Public : within a package interface is a public object, below shows an example where I wanted to add  Interface Note1 at two classes under the same package.

Code :
package javatemplate1;

import javafx.application.Application;
import javafx.scene.Scene;// 
import javafx.scene.control.Button;
import javafx.scene.layout.StackPane;
import javafx.stage.Stage;

 public class JavaTemplate1 extends Application implements Note1{
     // example of  extends vs Interface and javafx
     //StackedPane and Group comparison 1
     String str1 = proc1;
          public static void main(String[] args)  {
          System.out.println("main block executing");
          System.out.println("stage:: window starts");
          System.out.println("stage:: secne contnets");
   // Launching Application where Satge equals to window
         System.out.println("main block resumed");
         Process1 lproc1 = new Process1();
         System.out.println("from ..."+ lproc1.getClass());
         Process2 lproc2 = new Process2();
         System.out.println("from ..."+lproc2.getClass());

    public void start(Stage primaryStage) {
       // use Group or StackPane
    StackPane sp = new StackPane();
    Button btn1 = new Button(str1); 
      Scene scene = new Scene(sp,300,200);
 // a class can extends once an ExternalClass
// a class can't implement another class but many interfaces
 class Process1 extends ExternalClass1{
public Process1(){
    System.out.println("The product :"+ proc1);
     System.out.println(  n1); 
class Process2  implements Note1 {
    public Process2(){
     System.out.println("The product :"+proc1);
      System.out.println(  n1); 

// ExternalClass1
package javatemplate1;

 public class ExternalClass1 {
       String proc1 = "hello-class";
       int n1 = 13;  
}// external class 
interface Note1
    String proc1 = "world-interface";
    int n1 = 14;