Files Quiz

By Mickey Arnold
Last updated 10 months ago
5 Questions

What is the output by the code below using the following data file? nums.dat 2 5 7 Scanner file = new Scanner(new File("nums.dat")); System.out.println(file.nextInt());

What is the output by the code below using the following data file? nums.dat 2 5 7 Scanner file = new Scanner(new File("nums.dat")); System.out.println(file.nextInt()+file.nextInt());

What is the output by the code below using the following data file? nums.dat 2 5 7 Scanner file = new Scanner(new File("nums.dat")); file.nextInt(); System.out.println(file.nextInt()+file.nextInt());

What is the output by the code below using the following data file? nums.dat 3 2 5 7 Scanner file = new Scanner(new File("nums.dat")); int size = file.nextInt(); for(int i=1; i <= size; i++) { int num = file.nextInt(); out.print(num + " "); }

Question 5: What is the output by the code below using the following data file? nums.dat 3 2 5 7 Scanner file = new Scanner(new File("nums.dat")); int size = file.nextInt(); int x = 0; for(int i=1; i <= size; i++) { int num = file.nextInt(); x = x + num; } out.print( x + " " );