@@ -0,0 +1,1731 @@
+package java_problems.object_oriented_programming;%0D%0A%0D%0Aimport java.util.*;%0D%0A%0D%0A/*%0D%0A * Problem Statement: %0D%0A * The Java instanceof operator is used to test if the object or instance is an%0D%0A * instanceof the specified type.%0D%0A * %0D%0A * In this problem we have given you three classes in the editor, Student,%0D%0A * Rockstar and Hacker. In the main function we populated an ArrayList with%0D%0A * instances of these classes. count method counts how many instance of each%0D%0A * type are present in the ArrayList. Some lines of the code are missing, and%0D%0A * you have to fix it by modifying only 3 lines!%0D%0A * %0D%0A * Sample Input:%0D%0A * 5%0D%0A * Student%0D%0A * Student%0D%0A * Rockstar%0D%0A * Student%0D%0A * Hacker%0D%0A * %0D%0A * Sample Output:%0D%0A * 3 1 1%0D%0A */%0D%0Apublic class InstanceOfTutorial%0D%0A%7B%0D%0A   static String count(ArrayList mylist)%0D%0A   %7B%0D%0A      int a=0,b=0,c=0;%0D%0A      for(int i=0;i%3Cmylist.size();i++)%0D%0A      %7B%0D%0A         Object element=mylist.get(i);%0D%0A         if(element instanceof Student)%0D%0A            a++;%0D%0A         if(element instanceof Rockstar)%0D%0A            b++;%0D%0A         if(element instanceof Hacker)%0D%0A            c++;%0D%0A      %7D%0D%0A      String ret= Integer.toString(a)+%22 %22+ Integer.toString(b)+%22 %22+ Integer.toString(c);%0D%0A      return ret;%0D%0A   %7D%0D%0A%0D%0A   public static void main(String %5B%5Dargh)%0D%0A   %7B%0D%0A      ArrayList mylist=new ArrayList();%0D%0A      Scanner sc=new Scanner(System.in);%0D%0A      int t=sc.nextInt();%0D%0A      for(int i=0;i%3Ct;i++)%0D%0A      %7B%0D%0A         String s=sc.next();%0D%0A         if(s.equals(%22Student%22))mylist.add(new Student());%0D%0A         if(s.equals(%22Rockstar%22))mylist.add(new Rockstar());%0D%0A         if(s.equals(%22Hacker%22))mylist.add(new Hacker());%0D%0A      %7D%0D%0A      System.out.println(count(mylist));%0D%0A   %7D%0D%0A%7D%0D%0A%0D%0Aclass Student%7B%7D%0D%0Aclass Rockstar%7B%7D%0D%0Aclass Hacker%7B%7D

Add InstanceOfTutorial