Presentation is loading. Please wait.

Presentation is loading. Please wait.

Problem Solving #3: JVM ICS201-071. 2 Outline Review of Key Topics Review of Key Topics Problem 1 Problem 1 Problem 2 Problem 2 Problem 3 Problem 3 Problem.

Similar presentations


Presentation on theme: "Problem Solving #3: JVM ICS201-071. 2 Outline Review of Key Topics Review of Key Topics Problem 1 Problem 1 Problem 2 Problem 2 Problem 3 Problem 3 Problem."— Presentation transcript:

1 Problem Solving #3: JVM ICS201-071

2 2 Outline Review of Key Topics Review of Key Topics Problem 1 Problem 1 Problem 2 Problem 2 Problem 3 Problem 3 Problem 4 Problem 4

3 Form Groups of 3 Students and Work on the Following Problem

4 4 Review of Main Topics JVM 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

5 5 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. 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

6 6 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. 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

7 7 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, 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

8 8 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 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


Download ppt "Problem Solving #3: JVM ICS201-071. 2 Outline Review of Key Topics Review of Key Topics Problem 1 Problem 1 Problem 2 Problem 2 Problem 3 Problem 3 Problem."

Similar presentations


Ads by Google