0

Try catch

Class simple{ } Interface my { } Class test { public static void main(String [ ] args){ Try{ Class c =class.forName(“simple”); System.out.println(c.isInterface()); Class c2=class.forName(“my”); System.out.println(c2.isInterface( )); } Catch(exception e) { System.out.println(e);} }} Iam getting Output : false true Which statement is flase and which statement is true ?How can explain anyone....

14th May 2020, 4:17 PM
Haritha Vuppula
Haritha Vuppula - avatar
3 Respuestas
+ 1
Output tells you 1st one is false, 2nd one is true....! Yes. c.isInterface() is false because c is referencing to "Simple " which is class not interface. c2.isInterface() is true, because c2 is assigned to "my", which is interface...
14th May 2020, 5:33 PM
Jayakrishna 🇮🇳
+ 1
c2 is assigned as a refference to "my" interface. So it can store information related to " my" literal which is a name of interface.. A class is compatible type to interface so it can store information about inferface, like a class... You can read about Class class for more information.
14th May 2020, 5:51 PM
Jayakrishna 🇮🇳
0
tqsm Jayakrishna🇮🇳 but obj c2 is created for class
14th May 2020, 5:35 PM
Haritha Vuppula
Haritha Vuppula - avatar