Working on interface concept got error.. | Selenium Forum
M
Posted on 09/01/2017
Hello Sir,
Working on inference concept ,below code worked fine..but when i made "interface x=null; and pointed reference to FortisHospital and GovtHospital..I got error message as "

Exception in thread "main" java.lang.Error: Unresolved compilation problems:
Hospital.FortisHospital cannot be resolved to a type
Hospital.GovtHospital cannot be resolved to a type

at TestHospital.main(TestHospital.java:30)


Please look at my code.. And reslove the problem .plz..

-----------------------------------------------------------------------------
public class TestHospital {

public static void main(String[] args) {
//Hospital h=new Hospital(); illegal
FortisHospital f=new FortisHospital();
f.doscan();
f.dovaccination();
f.operate();
f.PhoneConsultation();

GovtHospital g=new GovtHospital();
g.doscan();
g.dovaccination();
g.operate();
// g.PhoneConsultation();

//interface ref=new class imple
Hospital h=new FortisHospital();
h.doscan();
h.dovaccination();
h.operate();
//h.PhoneConsultation();

Hospital h1=new GovtHospital();
h1=new FortisHospital();
//h1.phoneConsulation

Hospital x=null;
x.new FortisHospital(); // ERROR LINE OVER HERE
x.operate();
x.new GovtHospital(); //ALSO ERROR LINE OVER HERE
x.operate();

}
}


Thanks,
Deepak
------------------------------------------------

M
Replied on 10/01/2017

send a screen shot this code.


M
Replied on 10/01/2017

Please find the attachment.


M
Replied on 11/01/2017

try this.

Hospital x=null;
x=new FortisHospital(); // ERROR LINE OVER HERE
x.operate();
x=new GovtHospital(); //ALSO ERROR LINE OVER HERE
x.operate();