a. line no 14 : Widget w = new Widget();
line no 16 : w = new Widget();
both of the statement will be optimized at compilation Time because there is no change in the first object at line no 14
so the compiler will not assign two different object
b. In func1() variable p and q are initialized again hence it will be treated as the local variable of func1 only, the change in these variables will not affect the value of the instance variable.
c. when func2() is calling func1() then there will be new stack allocation for the func1() to store the variable of func1() which will available to only func1() scope.
d. Widget w = new Widget() it will be allocated in the heap
again in line 16 w= new Widget() it will again point to the same heap location.
e. funct1() stack frame will store
p,q,x,y and s along with the instance of the Calling function
f. func2() stack frame will store
w and instance of func1() called function
Stack heap questions 5. (16 points) (either 2 or 4 points each, look below for individual...
Question 2 [5 points) State if each of the below statements is True or False 1 2 3 The Compiler skips comments. A function can return a value of type array. An array index starts with 1. Pass by value is the default in CH, except when passing arrays as arguments to function The default storage class for local variables is static. A pointer provides an indirect means of accessing the value of a particular data item The logical operators...
Please help me to answer the 5 programming questions and give
some specific explanations, thanks a lot !!!
Question Consider a class hierarchy that includes a class called Creature, with subclasses called Unicorn and Dragon. The Creature class has a method called feelsLike, Not yet answered which is overridden in the Unicorn and Dragon class. Marked out of The feelsLike method of the Creature class returns "smooth", while the feelsLike method is overridden in the Unicorn class to return "fluffy"...
Write in JAVA Get Familiar with the Problem Carefully read the program description and look at the data file to gain an understanding of what is to be done. Make sure you are clear on what is to be calculated and how. That is, study the file and program description and ponder! Think! The Storm Class Type Now concentrate on the Storm class that we define to hold the summary information for one storm. First, look at the definition of...
------------------------------------------------------------------------------------------------------------
CODE ALREADY HAVE
BELOW---------------------------------------------------------------------------------------
public class LinkedQueue<T> implements
QueueADT<T>
{
private int count;
private LinearNode<T> head;
private LinearNode<T> tail;
public LinkedQueue()
{
count = 0;
head = null;
tail = null;
}
@Override
public void enqueue(T element)
{
LinearNode<T> node = new
LinearNode<T> (element);
if(isEmpty())
head =
node;
else
...
Q22 Consider the following 2 text files and Java program. 8 Points Answer the following questions keeping in mind that: • All three files are in the same directory, and there are no other files. • The program may crash. If the program crashes, answer the question with: "The program crashes" standings1.txt: 1 Valtteri Bottas 25 2 Charles Leclerc 18 3 Lando Norris 16 4 Lewis Hamilton 12 standings2.txt: 1 Valtteri Bottas 43 2 Lewis Hamilton 37 3 Lando Norris...
Please help with my car traffic simulator!
Code that I already have below, I do not know how to start it
off!
public class IntersectionSimulation
{
private final static int EAST_WEST_GREEN_TIME = 30 ;
private final static int[] NORTH_SOUTH_GREEN_TIMES = { 20, 24, 30, 42 } ;
private final static int[] CAR_INTERSECTION_RATES = { 3, 5, 10 } ;
private final static int[] CAR_QUEUEING_RATES = { 5, 10, 30 } ;
private final static int[] EXPERIMENT_DURATIONS = { 3*60, 5*60,...
True False Question 2 (3 points) Given a singly linked list with more than two nodes, to remove the second node from a linked list with only head reference, assume curr - head, next, you do Set curr.next to head.next Oset head. next to curr.next Set head, next to curr Oset head to curr.next TL th Question 3 (3 points) Given the following singly linked list (a list with four nodes), what will be the value stored at the last...
SHORT ANSWER QUESTIONS Part 1 Classes Abstraction: What is Abstraction in terms of representation? Specifically what choices does one make when creating a class that is an example of Abstraction? Encapsulation: What is encapsulation? What is information hiding? What does a public interface to a class consist of (not in the sense of actual java interfaces but what the client uses to manipulate objects of the class) What is an object of a class? What is the constructor? How do...
Multiple Choice Multiple Choice Section 4.1 Pointers and Dynamic Memory Consider the following statements: int *p; int i; int k; i = 42; k = i; p = &i; After these statements, which of the following statements will change the value of i to 75? A. k = 75; B. *k = 75; C. p = 75; D. *p = 75; E. Two or more of the answers will change i to 75. Consider the following statements: int i =...
Using C++ in Visual Studios
Rewrite the code to use a Stack instead of a Queue. You will
need to think about the differences in the Stack and Queue. Think
about how they operate and how the nodes may differ.
Modify the code as necessary.
You will need to push to the Stack, pop from the Stack, peek at
the Stack. You will need a member functions like in the example
code. Your program will need to show that everything...