Question: Suppose that the T is a reference to a container object that has a cursor and that T implements the Cursor interface from Topic 4

Suppose that the T is a reference to a container object that has a cursor and that T implements the Cursor interface from Topic 4, exercise 1. Which of the following code fragments would correctly perform iteration over all elements in T, assuming that T is non-empty? (check all that apply)
// Fragment A
T.goFirst()
while(T.itemExists()){
// Do something with T.item()
T.goForth()
}
// Fragment B
T.goFirst()
while(!T.after()){
// Do something with T.item()
T.goForth()
}
// Fragment C
T.goFirst()
while(T.item()!= null){
// Do something with T.item()
T.goForth()
}
// Fragment D
while(!T.before() && !T.after()){
// Do something with T.item()
T.goForth()
}
Group of answer choices
Fragment D
Fragment B
Fragment C
Fragment A

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!