Zum Hauptinhalt springen
Echtzeit-Radar & Feeds
Alle RSS Feeds ➔
👥 Community & Social
••••
Sicherheitslücken (CVE)CVE-2026-20786 | Intel NPU Driver out-of-bounds (Nessus ID 335912)(29.09.2026 um 05:01 Uhr)
••••••••••
Sicherheitslücken (CVE)CVE-2026-20786 | Intel NPU Driver out-of-bounds (Nessus ID 335912)(29.09.2026 um 05:01 Uhr)
••••••
Intelligence View
⚡ tsecurity.de Intelligence

day-29: Java Interface Explained: Rules, Real-World Examples, and Multiple Inheritance

What is interface in java? Interface like contract between two of them. Interface methods always in implement in different class. You and company: 1). 2 days leave can taken 2). upskill 1). Interface is not class - True public…

0
↗ Quelle (dev.to)
Reagiere als Erste:r — dein Feedback zählt!

What is interface in java?

Interface like contract between two of them.



Interface methods always in implement in different class.



You and company:

1). 2 days leave can taken

2). upskill



1). Interface is not class - True





public interface Company_rules {

int leaves = 10;
boolean variable_pay = true;

public void work();
public void rotate_shift();
public void relocate();
public void upskill();
public void apply_leave();
// method define and can't implement, no body

}

public interface Player_rules {

public int player_rules();
public int practice();
}

public class Amma {

public void eat() {
System.out.println("have you had your dinner...");
}
}


public class Employee extends Amma implements Company_rules, Player_rules {

public static void main(String[] args) {
// TODO Auto-generated method stub
Employee empl1 = new Employee();
empl1.work();

System.out.println(Company_rules.leave);
// Static variable from the interface can be access via interface name with variable name

System.out.println(Employee.variable_pay);
// Static variable from the interface can be access via implement
class name

}

@Override // definition by someone and implements
public void work() {
// TODO Auto-generated method stub

}

@Override
public void rotate_shift() {
// TODO Auto-generated method stub

}

@Override
public void relocate() {
// TODO Auto-generated method stub
System.out.println("move to blr...");

}

@Override
public void upskill() {
// TODO Auto-generated method stub

}

@Override
public void apply_leave() {
// TODO Auto-generated method stub

}
@Override
public int player_rules() {
// TODO Auto-generated method stub
return 0;
}

@Override
public int practice() {
// TODO Auto-generated method stub
return 0;
}
}







// @override means - method can be create by some and implement by someone



2). If method is interface mode if we again abstract that will be consider as redundant method. - True



3). methods in interface

return datatypes - public void apply_leave();

arguments - public void apply_leave(int leave_days);

method signature - access modifier - public, private, default, protect, final and static.



Static is common for all. and it will be called by class name.



final methods cannot be overridden.

final fields cannot be changed.



So, Interface won't support Final Key word.

Private also won't support.



interface also supports local variables:

public void apply_leave(int number);



It will support global variables:

int leave = 10;

boolean variable_pay = true;



if variable name is italy format that is static, in interface all the variables are static.



Is java supports multiple inheritance? yes, not directly




public class Employee extends Amma implements Company_rules { 
// multiple inheritance

public static void main(String[] args) {
// TODO Auto-generated method stub
Employee empl1 = new Employee();
empl1.work();
empl1.play();

}
}






Static variable from the interface can be access via interface name with variable name



Static variable from the interface can be access via implement class name




    {
System.out.println(Company_rules.leave);
System.out.println(Employee.variable_pay);

}







Class can be more than one interfaces



To create New Object:

Classname refer_name = new classname();

Calculator cal = new Calculator();



For validation purpose interface can verify the employee class.

This is also called as dynamic Biding.



interface_name from_interface_reference = new Class_name();

parent_class partent_Object = new parent_class();




     Company_rules manager = new Employee();
manager.apply_leave(); //dynamic biding

Amma object_amma = new Employee();
object_amma.eat();




you are allocating the new place for your manager and coach to validate the their given method in your class.



Dynamic Binding example chart with teacher role:



Image description



---------------------------------- end of the blog ---------------------------------------

Ähnliche Beiträge
🔍 Verwandte News

Auch interessante Nachrichten day-29: Java Interface Explained: Rules, Real-World Examples, and Multiple Inheritance

Thematisch verwandte Begriffe: day29, Java, Interface, Explained · 6 Treffer

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

Laden...

Beiträge werden geladen ...

Laden...

Videos werden geladen ...

💬 Kommentare werden geladen…
Zum Aktualisieren ziehen
ZERO-DAY CVE-2026-101093 | Cotonti through 1.0.0 contains a cross-site request forgery vulnerabili…
Advisory →
tsecurity.de Icon
Offline-Lesen, Eilmeldungen & 0ms Ladezeit

Installiere tsecurity.de direkt auf deinen Home-Bildschirm für das ultimative Vollbild-Magazinerlebnis ohne Browser-Leisten.

Nächster Beitrag