Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

1 : Given the two java source files below and the matching input, what is the final output of the program ( show your work

1: Given the two java source files below and the matching input, what is the final output of the program (show your work by using boxes and arrows)(refer mostly to blue boxes in picture attached)1: Given the two java source files below and the matching input, what is the final output of the program (show your
work by using boxes and arrows)
public class CallplaylistSong {
public static void main(String[] args){
PlaylistSong headObj = null;
PlaylistSong firstSong = null;
PlaylistSong secondSong = null;
PlaylistSong thirdSong = null;
PlaylistSong currObj = null;
headObj = new PlaylistSong ("head");
firstSong = new PlaylistSong ("Egmont");
headObj.insertAfter(firstSong) ;
secondSong = new PlaylistSong ("Fidelio");
firstSong.insertAfter (secondSong) ;
thirdSong = new PlaylistSong ("Nocturne");
secondSong.insertAfter(thirdSong);
currObj = headObj;
while (currobj != null){
currObj.PrintNodeData ();
currObj = currObj.GetNext ();
}
}
}
public class PlaylistSong (
private String name;
private PlaylistSong nextPlaylistSongRef;
PlaylistSong(){
this. name =;
nextPlaylistSongRef = null;
}
Playlistsong(String name){
this. name = name;
this.nextPlaylistSongRef = null;
}
PlaylistSong(String name, PlaylistSong nextLoc) f
this. name = name;
this.nextPlaylistSongRef = nextLoc;
}
void insertAfter(PlaylistSong nodeLoc){
Playlistsong tmpNext = null;
tmpNext = this.nextPlaylistSongRef;
this.nextPlaylistSongRef = nodeLoc;
nodeLoc.nextPlaylistSongRef = tmpNext;
}
PlaylistSong GetNext(){
return this.nextPlaylistSongRef;
}
Void PrintNodeData(){
System.out.println (this, name):
}
}
headObj null
headObj -> firstSong -> null
tmpNext -> null
tmpNext > null headObj > "head" & null
headObj -> "head" & null firstSong -> "Egmont" & null
headObj > "head" & null firstSong -> "Egmont" & null
tmpNext -> firstSong
I
tmpNext -> firstSong
headObj -> firstSong > secondSong > thirdSo
Output:
head
image text in transcribed

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

Students also viewed these Databases questions

Question

Explain walter's model of dividend policy.

Answered: 1 week ago