Explain java stack and heap

Assignment Help JAVA Programming
Reference no: EM13939954

I was given the following questions regarding stack and heap drawings. How are stack and heap drawings done? How would one go about these questions? I am posting the questions as reference, but I am requesting information about how to do these types of questions generally, not to have them done for me.

Stack and Heap Drawings:

1.
String s;
Fraction f, g;
Point w, x;
JFrame j;
f = new Fraction(25, 35);
g = f;
w = new Point(5, 10);

Draw a picture to illustrate what the stack and heap will look like.

2. String title = "Push Me"
JButton one = new JButton(title);
JButton two;
two = one;

Draw a picture to illustrate what the stack and heap will look like.

3. String y, z;
y = new String("This is easier than I thought!");
z = y.substring(11, 13);

Draw a picture of the stack and heap.

4. Consider the following code:
//Case 1
String word1 = "Easy";
String word2 = word1;
if (word1 == word2)
System.out.println("The words are the same");
else
System.out.println("The words are different");

This code will display "The words are the same" on the screen. However, if the code is written as:

// Case 2

String word1 = new String("Easy");
String word2 = new String("Easy");
if (word1 == word2)
System.out.println("The words are the same");
else
System.out.println("The words are different");

Most surprising however is that if you try the following code:

//Case 3

String word1 = "Easy";
String word2 = "Easy";
if (word1 == word2)
System.out.println("The words are the same");
else
System.out.println("The words are different");

This code will display "The words are the same" on the screen.

Reference no: EM13939954

Questions Cloud

Design and code a swing gui to translate test : Use a FLOWLAYOUT with a JTEXTAREA for the source text and separate JTEXTAREA for the translated text. Add a JBUTTON with an event to perform the translation
By how much time did the playstation beat the atlantic : Finally, divide 3000 statute miles by the statute miles per hour you obtained for the Atlantic and Playstation, to find the number of hours it took each yacht. Then answer this question: By how much time did the Playstation beat the Atlantic in trave..
Devise a comprehensive architecture of the system : Design of each the three capabilities in more detail by highlighting the components needed to address the business concerns discussed - Devise a comprehensive architecture of the system that includes the three capabilities and how they relate and i..
Investigate and compare their architectures : Survey modern embedded OS including iOS, Android, wearable OS and others. Investigate and compare their architectures, implementations, strengths, weakness, and security properties.
Explain java stack and heap : I am posting the questions as reference, but I am requesting information about how to do these types of questions generally, not to have them done for me.
Implement a queue class whose add and remove : Implement a Queue class whose add and remove methods are synchronized. Supply one thread, called the producer, which keeps inserting strings into the queue as long as there are fewer than 10 elements in it.
The key skills of an effective change agent : Task: Undertake a Literature Review (max 1500 words)- The Key Skills of an Effective Change Agent.'. The review is to focus solely on refereed academic publications (i.e. journal articles).
Calculate the total change in net income : Calculate the total change in net income if Alternative B is adopted. (Input all amounts as positive values, except cash outflows and any negative total change in net income which should be indicated by a minus sign.
Compare and contrast the terms diffusion and osmosis : List the four principal types of biological molecules, and give an example of each. List four characteristics of living things and give an example to illustrate each.

Reviews

Write a Review

JAVA Programming Questions & Answers

  1 write an application class that contains several

1 write an application class that contains several methods.nbspthe first method should be named greeting and should

  Programming principles please help me doing my assignment i

please help me doing my assignment i have attached my assignment requirement document refer it and send me the solution

  Number of space characters in a string

Write a loop that counts the number of space characters in a string - You need to implement a program to find the number of spaces.

  Application that calculates and displays the total payable

Write a java application that calculates and displays the total payable after applying discount on online grocery orders for N customers. The N should be set as a constant (final) in your application and choose a value between 7 and 9.

  Write a servlet that computes the total cost of the bulbs

Write a servlet that computes the total cost of the ordered light bulbs from above problem after adding 6.2 percent sales tax. The servlet must inform the buyer of exactly what was ordered in a table

  Explain how you would minimize the errors

What are the three types of errors that you can encounter in a Java program? Describe them, and explain how you would minimize the errors

  Write java program to reverse contents of original array

Write down the Java program method named reversal which returns the new array which is a reversal of original array. Use [5.0, 4.4, 1.9, 2.9, 3.4, 3.5] to test method.

  Calculation or a calendar of some activity.

1. Provide Java code for a simple class of your choice. Be sure to include at least one constructor, two methods and two fields. The fields should be private.Create a test class to construct and call the methods of your class. Describe your class and..

  Implement the hierarchy for a university with java classes

Implement the above hierarchy for a university with Java classes and their appropriate relationship. You can go three levels deep in the hierarchy (community member, employee, student, alumnus, faculty, staff). Use your best judgment of instance v..

  Write a mathematical recursive definition

Write a mathematical, recursive definition of p(n) - Prove that your answer to Part a is correct by using mathematical induction.

  Create a class representing a student

Create a second class that instantiates the first class with information about yourself. In the second class, create a class method that displays your name and GPA.

  Write a program that establishes two savings accounts

Write a program that establishes two savings accounts with saver1 having account number 10002 with an initial balance of $2,000, and saver2 having account 10003 with an initial balance of $3,000

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd