What is the output of the following code ?
import java.io.Serializable; public class MyClass{ public static void main(String ads[]){ if("s" instanceof Serializable){ System.out.println("Yes a string is instance of Serializable"); }else{ System.out.println("No it is not"); } } }
What is the output of the following code
public class MyClass{ public static void main(String ads[]){ if(1 instanceof int){ System.out.println("Yes 1 is an instance of int"); }else{ System.out.println("No it is not"); } } }
public class MyClass { public static void main(String ads[]){ File f = new File("aome"); try{ FileInputStream fis = new FileInputStream(f); }catch(IOException ioe){ if(ioe instanceof FileNotFoundException){ System.out.println("ioe is instance of FileNotFoundException"); }else{ System.out.println("No it is not"); } } } }
What will be the output of the program ?
public class MyClass{ public static void main(String ads[]){ if(2.4d instanceof Double){ System.out.println("Yes a double literal is of type Double"); }else{ System.out.println("No it is not"); } } }
What is the output of the following program ?
class Animal {} class Dog extends Animal {} class Cat extends Animal {} public class MyClass { public static void main(String ads[]){ Animal a = new Dog(); if(a instanceof Dog){ System.out.println(true); }else System.out.println(false); if(a instanceof Animal){ System.out.println(true); }else System.out.println(false); if(a instanceof Object) System.out.println(true); else System.out.println(false); } }
What will be the output of the following program ?
class Animal {} class Dog extends Animal {} class Cat extends Animal {} public class MyClass { public static void main(String ads[]){ Animal a = new Dog(); Dog d= (Dog)a; boolean b =d instanceof Dog ? true:false; System.out.println("testing if do is doodle "+b); } }