Question: 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
 1: Given the two java source files below and the matching

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!