Question: JAVA - Create a public static integer field named nextAddress and initialize nextAddress with 4 0 0 . Ex: If the input is 3 0

JAVA
-
Create a public static integer field named nextAddress and initialize nextAddress with 400.
Ex: If the input is 30, then the output is:
Next available address is 400.
Memory location has 30 elements and the elements are assigned with addresses from 400 to 519.
Next available address is 520.
public class MemoryLocation {
/* Your code goes here */
private int size;
private int startAddress;
private int endAddress;
public MemoryLocation(int newSize){
size = newSize;
startAddress = nextAddress;
endAddress = startAddress + size *4-1;
nextAddress += size *4;
}
public void print(){
System.out.print("Memory location has "+ size);
System.out.print(" elements and the elements are assigned with addresses from "+ startAddress);
System.out.println(" to "+ endAddress +".");
}
}

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!