GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — Java-Programs/interfaceExamples/IntefaceRules.java at master · divScorp/Java-Programs

Expand file tree

/

IntefaceRules.java

Copy path
More file actions
More file actions

Latest commit

 

History

History
History
64 lines (53 loc) · 1.67 KB
/

IntefaceRules.java

Copy path

File metadata and controls

64 lines (53 loc) · 1.67 KB
Raw
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package interfaceExamples;
public class IntefaceRules {
}
interface ExampleInterface1 {
// By default - public static final. No other modifier allowed
// value1,value2,value3,value4 all are - public static final
int value1 = 10;
public int value2 = 15;
public static int value3 = 20;
public static final int value4 = 25;
// private int value5 = 10;//COMPILER ERROR
// By default - public abstract. No other modifier allowed
void method1();// method1 is public and abstract
// private void method6();//COMPILER ERROR!
public static void m1() {//And we can provide definition for
//static method (From java 8 it's possible)
System.out.println("Static method");
}
//Interface can have a default definition of method.
//NEW FEATURE
default void method5() {
System.out.println("Method5");
}
}
interface ExampleInterface2 {
void method2();
}
interface test{
void te();
}
// An interface can extend another interface
// Class implementing SubInterface1 should
// implement method3 and method1(from ExampleInterface1)
interface SubInterface1 extends ExampleInterface1 {
void method3();
}
/*
* //COMPILE ERROR IF UnCommented //Interface cannot extend a Class interface
* SubInterface2 extends InterfaceRules{ void method3(); }
*/
/* A Class can implement multiple interfaces */
class SampleImpl implements ExampleInterface1, ExampleInterface2 {
/*
* A class should implement all the methods in an interface. If either of
* method1 or method2 is commented, it would result in compilation error.
*/
public void method2() {
System.out.println("Sample Implementation for Method2");
}
public void method1() {
System.out.println("Sample Implementation for Method1");
}
}
You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.