Files Quiz
By Mickey Arnold
starstarstarstarstarstarstarstarstarstar
Last updated 10 months ago
5 Questions
1 point
1
Question 1
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 point
1
Question 2
2.
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 point
1
Question 3
3.
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 point
1
Question 4
4.
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 point
1
Question 5
5.
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 + " " );