2nd Monthly Exam JAVA
2nd Monthly Exam JAVA
Test I. Match the Java code snippets in Column A with their corresponding functionalities in Column B
Write the LETTER ONLY on the space provided. (2pts each)
JAVA Code
Functionalities
1. System.out.println
2. Scanner scanner = new Scanner(System.in); A. Print output to the console. _____
3. scanner.close(); B. Initialize a Scanner object to read input from
4. break; the console. ________
5. exit = true; C. Close the Scanner object. _____
6. ArrayList<String> names = new ArrayList<>(); D. Terminate a loop or switch statement.______
7. public static void main(String[] args) { E. Set a boolean variable exit to true.______
8. import java.util.Scanner; F. Declare an ArrayList of strings. ________
9. default: G. Define the main method in a Java program.
10. int choice = scanner.nextInt(); ______
H. Import the Scanner class. _____
I. Specify a default case in a switch statement.
_____.
J. Read an integer input from the
console.______.
mport java.util.Scanner;
PROGRAM B
import java.utiIl.Scanner;
scanner.nextLine();
scanner.cloze();
}
}
}