Home / MCQ Bank / Computer
Computer Miscellaneous On Data Structures Difficulty: Medium

What will be the output of the following code in java? import java.util.ArrayList; public class LRU { public static void main(String[] args) { int page_frame = 3; int page_ref_string[] = {1, 2, 4, 1, 0, 3, 2, 0, 5, 4}; ArrayList<Integer> s=new ArrayList<>(page_frame); int count=0; int page_faults=0; for(int i:page_ref_string) { if(!s.contains(i)) { if(s.size()==page_frame) { s.remove(0); s.add(page_frame-1,i); } else s.add(count,i); page_faults++; ++count; } else { s.remove((Object)i); s.add(s.size(),i); } } System.out.println(page_faults); } }

Select the correct option to test your answer:

More Computer Questions

The universal format for PACS image storage and transfer is ______? . . . . . . . . occurs when a result is too large in magnitude to represent errors as a floating-point value of the required type. What will be the output of the following C++ code? #include <iostream> #include <map> using namespace std; int main () { multimap<char, int> mymultimap; mymultimap.insert(make_pair('y', 202)); mymultimap.insert(make_pair('y', 252)); pair<char, int> highest = *mymultimap.rbegin(); multimap<char, int> :: iterator it = mymultimap.begin(); do { cout << (*it).first << " => " << (*it).second << '\n'; } while ( mymultimap.value_comp()(*it++, highest) ); return 0; } What will happen if the browser encounters a script tag without an src attribute? . . . . . . . . is an input format for reading data from a relational database, using JDBC.