Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PLEASE ANSWER THE FOLLOWING QUESTIONS IN JAVA CODE: Q1. Write a Java program called Q1 that takes 3 integer values at the command prompt. It

PLEASE ANSWER THE FOLLOWING QUESTIONS IN JAVA CODE:

Q1. Write a Java program called Q1 that takes 3 integer values at the command prompt. It prints the three values with their memory addresses

Expected input: java Q1 10 20 30

Expected output: 0x22445512 10 0x2244AC12 20 0x221223F1 30

Q2. Write a Java class called Node. It contains the following attributes (fields). int age String name Write appropriate set and get methods. Create another class called Test with the main method; The main method takes upto three sets of input pairs (age, name) at the command prompt. Create three objects O1, O2 and O3 that store the information (input pairs). Print the memory address for each object and the input pairs. This time, export a JAR file (Q2.jar) and run the program from console.

Expected input: java -jar Q2 21 Mohamed 22 Ahmed 19 Saleh

Expected output: 0x22445512 21 Mohamed 0x2244AC12 22 Ahmed 0x221223F1 19 Saleh

Q3. Modify the Node class from Q2. Add another attribute Node next in the class. This time you will also print the address for the next attribute in each object. Export he program as Q3.jar and run it from the console using the same input provided in Q2.

Expected input: java -jar Q3 21 Mohamed 22 Ahmed 19 Saleh

Expected output: 0x22445512 21 Mohamed 0x2244AC13 0x2244AC12 22 Ahmed 0x2244AC11 0x221223F1 19 Saleh 0x2244AC12

Q4. Look carefully at the output of program in Q3 particularly the memory addresses. Can you describe your observation?

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

Step: 3

blur-text-image

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

Relational Database Design A Practical Approach

Authors: Marilyn Campbell

1st Edition

1587193175, 978-1587193170

More Books

Students also viewed these Databases questions