DEVRY ECET 370 Entire Course DEVRY ECET 370 Week 1 Lab 1 | Page 2

Exercise 3 : Shallow versus deep copy Provide an example of shallow copy of objects and an example of deep copy of objects .
Exercise 4 : Passing parameters to methods Write a function that swaps two Point objects . Use the code given below : import java . util .*; public class Main { public Main () { Scanner Scanner ( System . in ); System . out . print (" Enter x and y coordinates of first point : "); Point Point ( in . nextDouble (), in . nextDouble ()); System . out . print (" Enter x and y coordinates of second point : "); Point Point ( in . nextDouble (), in . nextDouble ()); swap ( p1 , p2 ); System . out . println (" Compile it , run it , and review the code that is given carefully . Note : The class Point implements the Comparable interface . The Comparable interface contains a single method : compareTo , which is used to compare two objects p and q of the same class type . When calling p . compareTo ( q ), it returns an integer . If this value is negative it means that p is smaller ; if it is equal to zero then , and if the value is positive , it indicates that p is greater than q .
Exercise 8 : Implementation of interfaces Using the class Point in the DocSharing area labeled “ Using interfaces ," write an application that declares an array of Points , fills the array with random points , and finds the smallest point in the array . Related Tutorials