Problem Solving #3: JVM ICS201-071 Outline Review of Key Topics Problem 1 Problem 2 Problem 3 Problem 4 2 Form Groups of 3 Students and Work on the Following Problem Review of Main Topics JVM Reflection – At runtime, the Java programmers can inspect various information including name of the class of a given object name of the superclass of that class names of interfaces that class methods that belong to that class etc 4 Problem 1 Write a program to show that each loaded type has only one instance of java.lang.Class associated with it, irrespective of how many times it is used in a class. Solution: Show Source Code Then run it in JCreator to check the output 5 Problem 2 Write a program to create an object of type String. Then print out the type of this object, its superclass, its package, all constructors, all methods, and all fields defined in this type. Solution: Show Source Code Then run it in JCreator to check the output 6 Problem 3 Modify the solution for problem 2 to prompt the user to type a class or an interface full name then print out whether the entered name is a class or interface, – All other information as in problem 2 Solution: Show Source Code Then run it in JCreator to check the output 7 Problem 4 Modify the solution for problem 3 to print out all the classes on the path starting from the entered class name till the Object class in addition to all as in problem 2 8