Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

2 public class HW2 { public static void main(String[] args) { Circle c1 = new Circle(); Circle c2 = new Circle); c1. radius = 10.0;

image text in transcribed

2 public class HW2 { public static void main(String[] args) { Circle c1 = new Circle(); Circle c2 = new Circle); c1. radius = 10.0; 12 //c1's id String circle_id_1 = ct.getClass().getName() + "@" + Integer. toHexString(System. identityHashCode(c1)); //c2's id String circle.id 2 = c2.getClass().getName() + "@" + Integer.toHexString(system. identityHashCode(c2)); 13 c2 = 1; //To-Do: 1. print radius and circle id for both c1 and c2 553A22 String s1 = "Java rocks!"; String s2 = "Java rocks!"; String s3 = new String("Java rocks"); //s1's id String str_id_1 = s1.getClass().getName() + "@" + Integer.toHexString(System. identityHashCode(s1)); //s2's id String str_id_2 = s2.getClass().getName() + "@" + Integer.toHexString(System. identityHashCode(s2)); //s3's id String str_id_3 = s3.getClass().getName() + "@" + Integer. toHexString(System. identityHashCode($3)); 28 //To-Do: 2. print s1, s2, and s3 ids //To-Do: 3. change s1, s2, and s3 to "Hello Java" using the new operator // For example, s1 = new String("Hello Java"); // Don't use string literal, e.g., s1 ="Hello Java"; 33 //To-Do: 4. Then, update and show their id again

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Fundamentals Of Database Systems

Authors: Sham Navathe,Ramez Elmasri

5th Edition

B01FGJTE0Q, 978-0805317558

More Books

Students also viewed these Databases questions