java practical interface
/*
interface ---aker besi impliment kora jay kintu class aktai extend
kora jay.
abstruct----onek interfaceko aksathe implement kore class bananno jaya
also akta class extend kora jay.
*/
package com.company;
interface Bicycle{
int a =50;
void applybreak(int decrement);
void speedup (int increment);
}
interface HornBicycle{
void blowHornk3g();
void blowHornk1g ();
}
class avoncycle implements Bicycle,HornBicycle{
void blowhorn(){
System.out.println("pee pee poo poo.tujhe dekha to yeah jana sanam");
}
//----------interface method alway public------
public void applybreak(int decrement){
System.out.println("apply break");
}
public void speedup (int increment){
System.out.println("applyying speedup");
}
public void blowHornk3g(){
System.out.println("pe pe pe pe kavi khusi khavi gam");
}
public void blowHornk1g (){
System.out.println("mya hu na po po po po");
}
}
public class cwh_chapter11_interfaces {
public static void main(String[] args) {
avoncycle cycleharry=new avoncycle();
cycleharry.applybreak(2);
System.out.println(cycleharry.a);
//but you can not create propeties in interface----------
//you cannot modify the properties in interfaces as their final
//---------//cycleharry.a=80;
System.out.println(cycleharry.a);
cycleharry.blowHornk3g();
cycleharry.blowHornk1g();
//multiple inheritance is not supported in java
/*
when there exist method with same signature in both super class.
java does not support multiple inheritance directory but similar
concept can be achieved usuing interface
a class can implement multiple interfaces and extend
a class at the same time
*/
}
}
Comments
Post a Comment