Final Exam Study CSE 1322 JAVA

Lakukan tugas rumah & ujian kamu dengan baik sekarang menggunakan Quizwiz!

The Boolean expression !(A || B) is equivalent to which of the following?

!A && !B

What is the output of the following code: class Wrong extends Exception { public Wrong(String message) { super(message); } } class Main { public static void doStuff(int x) throws Wrong { if(x<0) { throw new Wrong("Too Low"); } else if(x==0) { System.out.println(x); } else { doStuff(x-1); System.out.println(x); } } public static void main(String[] args) { try { doStuff(3); System.out.println("---"); doStuff(-1); } catch(Exception e) { System.out.println(e.getMessage()); } } }

0 1 2 3 --- Too Low

Given this method: public static int do_stuff(int x) { if(x==0) { return 1; } else { return do_stuff(x-1); } } What will the method return if called as follows: do_stuff(15);

1

class Main { public static void addtwo(int[] numArray) { numArray[0]+=2; } public static void main(String[] args) { int[] myNumbers = new int[] {1,2,3,4,5}; System.out.println(myNumbers[0]); } }

1

int x=10;for(int i=5;i<0;i--) {x++;}System.out.println(x);

10

import java.util.ArrayList; class Main {public static void main(String[] args) {ArrayList<Integer> myNumbers = new ArrayList<Integer>();myNumbers.add(10);myNumbers.add(20);myNumbers.add(30);myNumbers.add(40); int num=0;for(int x : myNumbers) {num+=x;}System.out.println(num);}}

100

What is the output of the following code? class Parent{ public int stuff() { return 1; } } class ChildOne extends Parent { @Override public int stuff() { return 2; } } class ChildTwo extends Parent { @Override public int stuff() { return 3; } } class MainClass { public static void Main (string[] args) { Parent var1=new Parent(); ChildOne var2=new ChildOne(); ChildTwo var3=new ChildTwo(); Parent var4=new ChildOne(); Parent var5=new ChildTwo(); int sum=var1.stuff() + var2.stuff() + var3.stuff() + var4.stuff() + var5.stuff(); System.out.println ("Sum is "+sum); } }

11

Given the following method: public static int pblmOne(int myNum){ if (myNum < 2) { return 3; } else { return 2 + pblmOne(myNum-2); } }If it is called as follows, what is the output: PRINT(pblmOne(10));

13

interface IA {public void do_stuff1();} abstract class B { public abstract void do_stuff2(); public int do_stuff3() { return 2; } } class C extends B implements IA { @Override public void do_stuff1() { int a=1; } @Override public void do_stuff2() { int b=1; } } class Main { public static void main(String[] args) { C myC = new C(); System.out.println(myC.do_stuff3()); } }

2

import java.util.ArrayList; class Stuff {private int x; public void setx(int y) {x=y;} public int getx() {return x;}} class Main { public static void main(String[] args) { ArrayList<Stuff> myNumbers = new ArrayList<Stuff>(); for(int i=0;i<5;i++) { Stuff myStuff = new Stuff(); myStuff.setx(i*10); myNumbers.add(myStuff); } System.out.println(myNumbers.get(2).getx()); } }

20

Given the following code: public static int do_stuff(int x) { if(x==0) { return 1; } else { return 1 + do_stuff(x-2); } } What is returned from this code if called as follows: do_stuff(4);

3

Given the following method: public static int recursive(int n) { if(n<=1) { return 1; } else { return 2+recursive(n/2); } } What is the value of x after the following call: int x = recursive(3);

3

Given the following method: public static int do_stuff(int x) { if(x<=0) { return 1; } else { return do_stuff(x-1)+do_stuff(x-2); } }What will the value of ans be after the method is called like this: int ans=do_stuff(2);

3

Assuming you have a Queue (myQueue) and a Stack (myStack), what would the output of the following operations be: myQueue.enqueue(10); myQueue.enqueue(20); myQueue.enqueue(30); myStack.push(myQueue.dequeue()); myStack.push(myQueue.dequeue()); myStack.push(myQueue.dequeue()); System.out.println(myStack.pop()); System.out.println(myStack.pop()); System.out.println(myStack.pop());

30 20 10

Given the following method: public static int myFunc(int x, int y) { if(x==0) { return y; } else { return myFunc(x-1,y+1); } } What is the value of x after the following call: int x = myFunc(0,4);

4

What is the output of the following code? import java.util.ArrayList; class Main { public static void main(String[] args) { ArrayList<Integer> myNumbers = new ArrayList<Integer>(); myNumbers.add(10); myNumbers.add(20); myNumbers.add(30); myNumbers.add(40); System.out.println(myNumbers.get(myNumbers.size()-1));}}

40

What is the value of head.next.previous.data in this linked list? ________ next _________ next _________ next head --> | data=5 | ------> | data=10 | ------> | data=15 | ------|| || -------| |<-------- | | <--------| | previous| | previous | | previous| | ---------- --------- ---------

5

Given the following method: public static int myFunc(int x, int y) { if(x==0) { return y; } else { return myFunc(x-1,y+1); } } What is the value of x after the following call: int x = myFunc(2,4);

6

Assuming you have a linked list that looks like this: ________ next ________ next ________ next head --> | data=2 | ------> | data=4 | ------> | data=6 | ------|| ---------- -------- -------- What is the output of the following method assuming myFunc is called and passed head? class Node { public int data; public Node next; } public void myFunc(Node current) { if(current==null) { return; } else { myFunc(current.next); System.out.println(current.data); } }

6 4 2

Assuming you have a Queue (myQueue) and a Stack (myStack), what would the output of the following operations be: myQueue.enqueue(1); myQueue.enqueue(2); myQueue.enqueue(3); myQueue.enqueue(4); myQueue.enqueue(5); myQueue.enqueue(6); myQueue.dequeue(); myStack.push(myQueue.dequeue()); myStack.push(myQueue.dequeue()); myStack.push(myQueue.dequeue()); myStack.push(myQueue.dequeue()); myStack.push(myQueue.dequeue()); System.out.println(myStack.pop()); System.out.println(myStack.pop()); System.out.println(myStack.pop());

6 5 4

What does the following code output? Java int x=10; while(x>2){x-=2;System.out.println(x);} int x=10; while(x>2){x-=2;Console.WriteLine(x);}

8 6 4 2

What is the output of the following code: class Main { public static void do_stuff() { int[] myNums = new int[5]; myNums[5]=1; } public static void main(String[] args) { try { do_stuff(); } catch(IndexOutOfBoundsException e) { System.out.println("A"); } catch(RuntimeException e) { System.out.println("B"); } catch(Exception e) { System.out.println("C"); } } }

A

What is the output of the following code? class A { public void do_it() { System.out.println("A"); } } class B extends A {public void do_stuff() {System.out.println("B");}} class Main { public static void main(String[] args) { A myClass=new A();myClass=new B();myClass.do_it(); } }

A

class A { public void do_it() { System.out.println("A"); } } class B extends A {public void do_stuff() {System.out.println("B");}} class Main { public static void main(String[] args) { A myClass=new A();myClass=new B();myClass.do_it(); } }

A

What is the output of the following code: class Main { public static void do_stuff() { int[] myNums = new int[5]; myNums[5]=1; } public static void main(String[] args) { try { do_stuff(); } catch(Exception e) { System.out.println("A"); } finally { System.out.println("X"); } } }

A X

After executing the following code, what will be the contents of A.txt? import java.io.*; import java.io.File; import java.io.IOException; class Main { public static void write_file(String filename, String line, int x) { try { File myFile=new File(filename); PrintWriter theFile = new PrintWriter(myFile); for(int i=0;i<x;i++) { theFile.println(line); } theFile.close(); } catch(IOException e) { System.out.println("Error reading file: "+e.getMessage()); } } public static void main(String[] args) { write_file("A.txt","Hi",3); write_file("A.txt","Hi",3); } }

A.txt will contain the word Hi on three lines

After executing the following code, what will be the contents of A.txt? import java.io.*; import java.io.File; import java.io.IOException; class Main { public static void write_file(String filename, String line, int x) { try { File myFile=new File(filename); PrintWriter theFile = new PrintWriter(myFile); for(int i=0;i<x;i++) { theFile.println(line); } theFile.close(); } catch(IOException e) { System.out.println("Error reading file: "+e.getMessage()); } } public static void main(String[] args) { write_file("A.txt","Hi",3); } }

A.txt will contain the word Hi on three lines

Which of the following does not have a body?

An abstract method

What is the output of the following code: class Main { public static void do_stuff() { int[] myNums = new int[5]; myNums[5]=1; } public static void main(String[] args) { try { do_stuff(); System.out.println("A"); } catch(Exception e) { System.out.println("B"); } } }

B

Given the following code: public static int question(int m) { if(m==0) { return 1; } else { return m*question(m-2); } } Which of the following calls will cause infinite recursion? A. int x=question(10); B. int x=question(11); C. int x=question(0); D. int x=question(-2);

B and D will cause infinite recursion.

Given the following UML, which statement below is not valid?

B myvar = new A();

What does the following statement do? Thread.sleep(10000);

Causes the current thread to pause for 10 seconds

Consider the following code for class XYZ public class XYZ { private int myNum; public XYZ (int n1) { myNum = n1; } } Which of the following statements is TRUE about class XYZ

Class XYZ inherits from the Object class

class Main { public static void swap(String str1, String str2) { String holdString; holdString = str1; str1 = str2; str2 = holdString;} public static void main(String[] args) { String s1 = "Computers"; String s2 = "Rock"; swap(s1, s2); System.out.println(s1+" "+s2);}}

Computers Rock

What is the output of the following code? class Node { public char letter; public Node next; public Node(char letter) { this.letter=letter; next=null; } } class Main { public static void dostuff(Node head) { if(head!=null) { dostuff(head.next); System.out.print(head.letter); } } public static void main(String[] args) { Node head = null; head=new Node('A'); head.next=new Node('B'); head.next.next=new Node('C'); head.next.next.next=new Node('D'); head.next.next.next.next=new Node('E'); dostuff(head); } }

EDCBA

Code written to take advantage of parallel processing will always run faster than code which is not written for parallel processing?

False

Making a program multithreaded will always ensure it runs faster?

False

The Socket object in Java, and the TCPClient object in C# can be used to read information from a remote server, but not write to it?

False

The following code will compile and output 8? class Stuff {public int x=7;} class Main { public static void main(String[] args) { Stuff.x=8; System.out.println(Stuff.x); } }

False

You can overload a constructor in a derived class?

False

Assume you have a file called QuizGrades.csv with the following content: Student1,100,90,80,90,80 Student2,70,80,85,85,80 Student3,100,100,100,95,100 Student4,70,70,80,70,80 |Student5,90,90,90,90,100 Which of the following lines is the correct way to open a text file such as the above for reading.

File myFile = new File("QuizGrades.csv"); Scanner myScan = new Scanner(myFile);

What is the output of the following code? class MyFirstThread implements Runnable { static int next_tid=1; int tid; public MyFirstThread() { tid=next_tid++; } public void run() { System.out.println("I'm thread "+tid); } } class Main { public static void main(String[] args) { MyFirstThread t1 = new MyFirstThread(); MyFirstThread t2 = new MyFirstThread(); MyFirstThread t3 = new MyFirstThread(); Thread thread1 = new Thread(t1); Thread thread2 = new Thread(t2); Thread thread3 = new Thread(t3); System.out.println("Let's go!"); thread1.start(); thread2.start(); thread3.start(); System.out.println("Done"); } }

It's impossible to tell the order the statements will appear in.

Which of the following blocks of code will successfully ask a user for a number, multiply that number by 2, and print the result

Java import java.util.Scanner; System.out.println("Enter a number to be doubled:"); Scanner myscanner = new Scanner(System.in); int num=myscanner.nextInt(); num*=2; System.out.println("Your number doubled is "+num);

If you call do_stuff() from main, what if any exception will you see? public static void do_stuff() { int[] myNums = new int[5]; myNums[5]=1;}

Java: ArrayIndexOutOfBoundsException C#: IndexOutOfRangeException

If you call do_stuff() from main, what if any exception will you see? public static void do_stuff() { int[] myNums = new int[5]; myNums[5]=1;}

Java: ArrayIndexOutOfBoundsException C#: IndexOutOfRangeException

What is the output of the following code? class MyFirstThread implements Runnable { static int next_tid=1; int tid; public MyFirstThread() { tid=next_tid++; } public void run() { System.out.println("I'm thread "+tid); } } class Main { public static void main(String[] args) { MyFirstThread t1 = new MyFirstThread(); MyFirstThread t2 = new MyFirstThread(); MyFirstThread t3 = new MyFirstThread(); System.out.println("Let's go!"); Thread thread1 = new Thread(t1); Thread thread2 = new Thread(t2); Thread thread3 = new Thread(t3); System.out.println("Done"); }}

Let's go! Done

Which line or lines of code below will cause compile errors? class Parent { public int x; } class Child extends Parent { public void doStuff() { System.out.println("I'm a child"); } } class Main { public static void main(String[] args) { Parent p1 = new Parent(); Child c1 = new Child(); Parent p2 = new Child(); p1.doStuff(); //Line 1 c1.doStuff(); //Line 2 p2.doStuff(); //Line 3 ((Child)p2).doStuff(); //Line 4 } }

Line 1 Line 3

Java boolean a=false; boolean b=true;boolean c=false;boolean d=true; if((a) && (b || c) && d) { System.out.println("Yes"); }else { System.out.println("No");}

No

Will the code compile abstract class A { public int do_stuff1() { return 3; } } class B extends A { @Override public int do_stuff1() { return 4; } public int do_stuff2() { return 7; } } class Main { public static void main(String[] args) { //Note the polymorphism: A myB = new B(); myB.do_stuff1(); myB.do_stuff2(); } }

No, class A has no do_stuff2() therefore you can't call do_stuff2() on myB in main.

Searching for a value in a Binary Search Tree with N nodes, will take approximately how much time?

O(logN)

When a set of methods have the same name but different types/number of parameters in the same class, they are called:

Overloaded methods

What is the output of the following statements: //Java: String s="Hi"; for(int i=0;i<3;i++) { System.out.print("S"+s); }

SHiSHiSHi

What is the output of the following code: class Main { public static void main(String[] args) { int[] myArray = new int[5]; try { for(int i=0;i<=5;i++) { myArray[i]=i; } System.out.println(myArray[3]); } catch(Exception e) { System.out.println("Something went wrong"); } } }

Something went wrong

What is the output of the following code? import java.util.ArrayList; class Widget { public String name; } class Inventory { public static ArrayList<Widget> factoryInventory = new ArrayList<Widget>(); } class Factory extends Inventory implements Runnable { public void run() { for(int i=0;i<100;i++) { Widget newWidget = new Widget(); newWidget.name="Widget"+i; factoryInventory.add(newWidget); } } }class Main { public static void main(String[] args) { Inventory myInventory=new Inventory(); Thread[] factories = new Thread[100]; for(int i=0;i<100;i++) { factories[i]=new Thread(new Factory()); factories[i].start(); } System.out.println(myInventory.factoryInventory.size()); }}

The output will be different each time you run it.

In GUI coordinate system, which of the following positions refers to the coordinates (0,0)?

The top left corner of the GUI box

If you wanted to find if a particular number was present in an array of one million integers, which of the following approaches will not work?

They would all work.

Given the following code: public static int do_stuff(int x) { if(x==0) { return 1; } else { return 1 + do_stuff(x-2); } } What is returned from this code if called as follows: do_stuff(3);

This code crashes with a stack overflow

A stack is a data structure that follows the principle of Last In First Out. Whereas a queue is a data structure that follows the principle of First in First Out?

True

An exception is a notification that something interrupts the normal program execution. Exceptions provide a programming paradigm for detecting and reacting to unexpected events.

True

Given the previous 3 questions, the following would be an appropriate catch block? catch(IOException e) { System.out.println("Error reading file: "+e.getMessage()); }

True

If a recursive method has no base case (bottom), or if the base case is never reached, it will become infinite and the result will be stack overflow error.

True

In a doubly-linked lists each node contains its value and two pointers: One which points to the next node One which points to the previous node

True

In dynamic binding or late binding, the type of object is determined at run-time.

True

Pressing a GUI button normally causes an event to occur.

True

Recursion represents a powerful programming technique in which a method makes a call to itself from within its own method body.

True

The code within the finally block is always executed, no matter how the program flow leaves the try block. This guarantees that the finally block will be executed even if an exception is thrown.

True

The following code will compile and output 8? class Stuff {public static int x=7; public static void do_stuff() {x++;System.out.println(x);}} class Main { public static void main(String[] args) { Stuff.do_stuff(); } }

True

The stack trace contains detailed information about the exception including where exactly it occurred in the program. The stack trace is very useful for programmers when they try to understand the problem causing the exception.

True

What is the output of the following code? class Main { public static String question(String x) { if(x.length()==0) { return x; } else { return "X"+question(x.substring(0,x.length()-1)); } } public static void main(String[] args) { String y=question("ABCDE"); System.out.println(y); } }

XXXXX

Will the code compile abstract class A { private int x; public A() { x=7; } public A(int y) { x=y; } public abstract int do_stuff1(); public abstract int do_stuff2(); } class B extends A { public B() { super(7); } public B(int y) { super(y); } @Override public int do_stuff1() { return 4; } @Override public int do_stuff2() { return 4; } } class Main { public static void main(String[] args) { B myB = new B(5); } }

Yes

Will the following code compile? abstract class A { public int do_stuff1() { return 3; } public abstract int do_stuff2(); } class B extends A { @Override public int do_stuff1() { return 4; } @Override public int do_stuff2() { return 7; } } class Main { public static void main(String[] args) { B myB = new B(); myB.do_stuff1(); myB.do_stuff2(); } }

Yes

class Counter { private int seconds=0; public void addOne() { seconds++; } public void subtractOne() { seconds--; } public int currentCount() { return seconds; } } class Main { public static int doStuff(int x, Counter a) { x++; a.addOne(); return x+a.currentCount(); } public static void main(String[] args) { int x=0; int y=0; Counter a = new Counter(); a.addOne(); y=doStuff(x,a); System.out.println("a "+a.currentCount()+" x "+x+" y "+y); } }

a 2 x 0 y 3

Which of these is correct?

a base class is a parent class or super class

Java class Numbers { public int a; public static int b; public Numbers(int c) { a+=c; b+=c; } public int get_b() { return b; }} class Main { public static void main(String[] args) { Numbers n1=new Numbers(2); Numbers n2=new Numbers(3); System.out.println("a: "+n2.a+" b: "+Numbers.b);}}

a: 3 b: 5

class Stuff { public int number=1; } class Main { public static void do_things(int y) { y+=3; } public static void do_other_things(Stuff y) { y.number+=3; } public static void main(String[] args) { int a=3; Stuff myStuff = new Stuff(); do_things(a); do_other_things(myStuff); System.out.println("a:"+a+" myStuff.number:"+myStuff.number); } }

a:3 myStuff.number:4

Which of the following types cannot be used as the parameter for a switch statement?

boolean (Java) or bool (c#)

Given the following code, which of the following is the correct definition for class B, such that the output of the program is 1 2 3 : [Hint: Pay close attention to the Access Modifiers] public class A { private int x; private int y; public A(int a, int b) { x=a; y=b; } @Override public String toString() { return x+" "+y; } } //Class B goes here. class Main { public static void main(String[] args) { B myB=new B(1,2,3); System.out.println(myB); } }

class B extends A { private int z; public B(int a, int b, int c) { super(a,b); z=c; } @Override public String toString() { return super.toString()+" "+z; } }

Given the following code, which of the below definitions for a child class ChocolateBar is valid: [Hint: Pay attention to the Access Modifiers of the attributes in CandyBar] class CandyBar { private double cost; private String manufacturer; private String name; public CandyBar(double c, String m, String n) { cost=c; manufacturer=m; name=n; } public double getcost() { return cost; } }

class ChocolateBar extends CandyBar { private String chocolatetype; public ChocolateBar(double c, String m, String n) { super(c,m,n); chocolatetype="Milk";}}

Given the following code, which method will cause a compile error: abstract class A { public int do_stuff1() { return 3; } public abstract int do_stuff2() {}; public void do_stuff3() { return; } public abstract int do_stuff4(); }

do_stuff2()

class Animal { public void sound() { System.out.println("eek"); } } class Cow extends Animal { @Override public void sound() { System.out.println("moo"); } }class Dog extends Animal {} class Main { public static void main(String[] args) { Animal a1=new Animal(); a1.sound(); Cow a2=new Cow(); a2.sound(); Dog a3=new Dog(); a3.sound(); }}

eek moo eek

The following code will not compile as is. It is missing a line that needs to be inserted where the "//Missing Line" comment is. Which line of code will fix the compile error? class House { public int square_footage; public int stories; public House() { square_footage=0;stories=1;}} class Main {public static void main(String[] args) { House h1; //Missing Line h1.square_footage=1;}}

h1 = new House();

This method is designed to find the lowest integer in an array. Which of the following choices is the correct recursive call? public static int lowest(int[] a,int start) { if(start>=a.Length-1) { return a[start]; } else { //MISSING RECURSIVE CALL GOES HERE } }

if(a[start]<lowest(a,start+1)) { return a[start]; } else { return lowest(a,start+1); }

Which of the following are valid variable declarations: (Select ALL that are valid)

int a=1102; long b=1; Java: String d=""; C#: string d="";

Abstract methods are used when defining

interfaces

The relationship between a parent class and a child class is referred to as a(n) ________ relationship.

is-a

According to the following UML, if a new object of B is created in main as follows: B myB = new B(); Which of the following statements is NOT valid in main?

myB.do_stuff3();

Why does the following code not compile? public class XYZ { private int myNum; public XYZ() { myNum=0; } public XYZ(int n1) { myNum=n1; } } public class ABC extends XYZ { private int num2; public ABC() { myNum=0; num2=0; } pubilc ABC(int n1) { myNum=n1; num2=n1*2; } } class Main { public static void main(String[] args) { ABC myABC = new ABC(); } }

myNum is defined as private in XYZ and as such is inaccessable in ABC.

What is the output of the following code? class Stuff { public int number=1; } class Main { public static void main(String[] args) { Stuff myStuff = new Stuff(); myStuff.number+=3; System.out.println("myStuff.number:"+myStuff.number); myStuff = new Stuff(); System.out.println("myStuff.number:"+myStuff.number);}}

myStuff.number:4 myStuff.number:1

The following is the code to play a guessing game. It will keep prompting until the user guesses the correct answer (50). While the user is guessing it'll count how many attempts it took the user to guess correctly. When the user correctly guesses the number, it outputs the number of guesses it took. What is the correct recursive statement that is missing from guess_num() method? import java.util.Scanner; class Main { public static int guess_num(int answer,int tries) { Scanner myScan=new Scanner(System.in); System.out.println("Guess a number"); int guess=myScan.nextInt(); if(guess==answer) { System.out.println("Correct"); return tries; } else { //What goes here? } } public static void main(String[] args) { int guesses=guess_num(50,1); System.out.println("It took you "+guesses+" guesses"); } }

return guess_num(answer,tries+1);

The following is the code to play a guessing game. It will keep prompting until the user guesses the correct answer (50). While the user is guessing it'll count how many attempts it took the user to guess correctly. When the user correctly guesses the number, it outputs the number of guesses it took. What is the correct recursive statement that is missing from guess_num() method? import java.util.Scanner; class Main { public static int guess_num(int answer,int tries) { Scanner myScan=new Scanner(System.in); System.out.println("Guess a number"); int guess=myScan.nextInt(); if(guess==answer) { System.out.println("Correct"); return tries; } else { //What goes here? } } public static void main(String[] args) { int guesses=guess_num(50,1); System.out.println("It took you "+guesses+" guesses"); } }

return guess_num(answer,tries+1);

To successfully sum all integers in an array, what should the missing line of code be: public static int sum_array(int[] myArray,int start) { if(start>myArray.length-1) { return 0; } //What goes here? }

return(myArray[start]+sum_array(myArray,start+1));

What method will contain the body of the thread?

run()

Assume you have a file called a.txt with the following content : jane,100 tim,80 janet,40 What is the output of the following code: import java.util.Scanner; import java.util.ArrayList; import java.io.*; class Score { public String name; public int theScore; public Score(String name, int theScore) { this.name=name; this.theScore=theScore; } } class Main { public static void main(String[] args) { ArrayList<Score> scoreCard = new ArrayList<Score>(); try { File scoreFile = new File("a.txt"); Scanner sf = new Scanner(scoreFile); while(sf.hasNextLine()) { String line=sf.nextLine(); String[] parts=line.split(","); Score newScore = new Score(parts[0],Integer.parseInt(parts[1])); scoreCard.add(newScore); } } catch(IOException e) { System.out.println(e.getMessage()); } System.out.println(scoreCard.get(1).name); } }

tim

Assume you have a file called QuizGrades.csv with the following content: Student1,100,90,80,90,80 Student2,70,80,85,85,80 Student3,100,100,100,95,100 Student4,70,70,80,70,80 Student5,90,90,90,90,100 Which of the following code snips correctly reads each line from the file correctly assigning it to a variable called line. You can assume the previous question correctly opened the file, and you have a variable myScan which allows you to access the file.

while(myScan.hasNextLine()) { String line=myScan.nextLine();}


Set pelajaran terkait

stats ch 2 test review (Just Q&A)

View Set

F.b) Trauma and Stressor-Related Disorders, Crisis and Response to Disaster

View Set

True/False Operating system chp 1-4

View Set

Chapter 21 The Immune System: Innate and Adaptive Body Defenses

View Set