Explore BrainMass
Share

Solving: JAVA Questions

This content was STOLEN from BrainMass.com - View the original, and get the already-completed solution here!

- The linked list that follows represents a stack. After we push the player (5, Joe, Sonic) onto the stack, what are first and last items on the stack?
(7,Ajay, NFL) -> (3, Sarah, Mario) -> (9, Jin, Golf) -> null
head

(7, Ajay, NFL0 and (9, Jin, Golf)
(5, Joe, Sonic) and (9, Jin, Golf)
(3, Sarah, Mario) and (5, Joe, Sonic)
(7, Ajay, NFL) and (5, Joe, Sonic)

A=

- The diagram that follows shows the current state of the stack represented by an array of 50 integers. After pushing 36, 88, and 62 onto the stack and popping three times from the stack, what will be the value of the top and what element will be stored at index top?
Index Item Stored
47(top) 28
46 98
... ...
3 17
2 12
1 20
0 45

Top is 49 and the element at index top is 62
Top is 47 and element at index top is 28
Top is 46 and element at index top is 98
Top is 50 and element at index top is 17

a=

- The diagram that follows shows the current state of a queque represented by circular array of 8 integers. After enqueuing 36, 100, 83, 77, and 62, what are the values of front and back, and what elements are stored at indexes front and back.
Index Item stored
7
6(back) 28
5 97
4 25
3 54
2(front) 12
1
0

A=

For these questions, consider the following classes from this chapter Player, PlayerNode, and PlayerLinkedList.

- What does this method of PlayerLinkedList class do?
Public void fool( Player p, Player q )
{
insert ( p );
insert ( q );
}

A=

- What does this method of PlayerLinkedList class do?
Public int f004( )
{
PlayerNode nd =head;
int i = 0;
while ( nd != null )
{
if (nd.getPlayer( ).getGame( ).equals( "Sonic") )
i++;
nd = nd.getNext( );
}
return i;
}

A=

- What does this method of PlayerLinkedList class do?
Public Boolean f008( )
{
if ( number0fitems <= 2 )
return false;
else
{
head.setNext( ( head.getNext ( ) ).getNext ( ) );
Number)fItems--;
return true;

A=

© BrainMass Inc. brainmass.com October 25, 2018, 8:59 am ad1c9bdddf
https://brainmass.com/computer-science/java/solving-java-questions-560171

Solution Preview

- A= first: (5, Joe, Sonic) and last: (9, Jin, Golf)

- Because, index 49 will be the top and you can push only 2 items, ...

Solution Summary

A few objective questions are solved.

$2.19
See Also This Related BrainMass Solution

The solution gives complete solutions for various questions on output of Java code. Each question is discussed in details.

What is the output of this code sequence?
Double a = 12.5;
System.out.println (a);

What is the output of this code sequence?
Float a = 13f;
System.out.println (a);

What is the output of this code sequence?
Int a = 13 /5;
System.out.println (a);

What is the output of this code sequence?
Int a = 12 / 6 *2;
System.out.println (a);

What is the output of this code sequence?
Int a =4 + 6 /2;
System.out.println (a);

What is the output of this code sequence?
Double a = 12.0 /5;
System.out.println (a);

What is the output of this code sequence?
Double a = (double) (12) /5;
System.out.println (a);

What is the output of this code sequence?
Int a=5;
A++;
System.out.println (a);

What is the output of this code sequence?
Int a =5
System.out.println (--a);

What is the output of this code sequence?
Int a=5;
A /= 6;
System.out.println (a);

Write the pseudocode for a program that finds the product of two numbers.

Write the pseudocode for a program that finds the sums of the numbers input that are greater than or equal to 10 and the numbers input that are less than 10.

View Full Posting Details