Quiz 9
Friday
With a piece of paper, write down your name and answers to the following questions.
What is an interface?
- An interface is a collection of public methods.
- An interface is a collection of interactive graphic components.
- An interface is a collection of method definitions and constants.
- An interface is a class that serves as the superclass of other classes.
What will the following program print?
import java.util.StringTokenizer; public class Program { public static void main(String[] args) { String str = "one#two@three"; StringTokenizer strTokenizer = new StringTokenizer(str, "&%@#", true); while (strTokenizer.hasMoreTokens()) System.out.println(strTokenizer.nextToken()); } }
Answer:
one
#
two
@
threeIs the following statement correct, and why?
Every class has a
toString
method and anequals
method inherited from theObject
class.Answer: Yes, this statement is correct.
With the following class hierarchy...
Is the following code correct, and why?
public class Program { public static void main(String[] args) { try { Scanner scanner = new Scanner(System.in); int num = scanner.nextInt(); } catch (NoSuchElementException e) { System.err.println("No Such Element"); } catch (InputMismatchException e) { System.err.println("Input Mismatch"); } } }
Correction:
public class Program { public static void main(String[] args) { try { Scanner scanner = new Scanner(System.in); int num = scanner.nextInt(); } catch (InputMismatchException e) { System.err.println("Input Mismatch"); } catch (NoSuchElementException e) { System.err.println("No Such Element"); } } }
Student Performance and Statistics
A histogram of student performance on percentage grades for Quiz 9 on Friday.
A table showing the average performance for each question in Quiz 9 on Friday.