Files Quiz
star
star
star
star
star
Last updated over 1 year ago
5 questions

1
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());
1
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"));
System.out.println(file.nextInt()+file.nextInt());

1
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
2
5
7
Scanner file = new Scanner(new File("nums.dat"));
file.nextInt();
System.out.println(file.nextInt()+file.nextInt());
1
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 + " ");
}
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 + " ");
}

1
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 + " " );
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 + " " );