java (default method)(inheritance-interface)

default method 


package com.company;



interface mycamera{
void TakeSnap();
void recordvideo();
//default method add kora jay jokhn new inrerface er intilize er sathei method declare korar jonno,
//jodi pore method declas kora hoy tale r default kaj korbe na
default void record4kvideo(){
System.out.println("recording in 4k......");
}

}
interface mywifi{
String[] getNetworks();
void connecttonetwork(String network);
}

class cellphone{
void callnumber(int phonenumber){
System.out.println("calling..."+phonenumber);
}
void pickcall(){
System.out.println("connecting....");
}

}

class mysmartphone extends cellphone implements mywifi,mycamera {

public void TakeSnap() {
System.out.println("taking snap");
}
public void record4kvideo() {
System.out.println("taking snap and hd... record video. in 4k.....");
}

public void recordvideo() {
System.out.println("taking video");
}

public String[] getNetworks() {
System.out.println("getting list of network");
String[] networklist = {"voda", "idea", "jio", "airtel"};
return networklist;
}
public void connecttonetwork(String network) {
System.out.println("connecting to" +network);
}

}


public class cwh_chapter11_practiceset {
public static void main(String[] args) {
mysmartphone ms= new mysmartphone();
ms.record4kvideo();
String[] ar= ms.getNetworks();
for ( String item:
ar) {
System.out.println(item);

}

}
}





inheritance-interface




package com.company;

interface sampleinterface{
void method1();
void method2();
}
interface childsampleinterface extends sampleinterface{
void method3();
void method4();

}

class mysampleclass implements childsampleinterface{
public void method1(){
System.out.println("method1");
}
public void method2(){
System.out.println("method2");
}
public void method3(){
System.out.println("method3");
}
public void method4(){
System.out.println("method4");
}
}

public class cwh_chapter11_inheritance_interface {

public static void main(String[] args) {
mysampleclass obj =new mysampleclass();
obj.method1();
obj.method2();
obj.method3();
obj.method4();


}
}

Comments

Popular posts from this blog

java chapter11 practice question on abstruct class and interfaces

java practice set 8

new stored procidure with interval and frequery code