Sample Quiz For Testing

2 Questions | Attempts: 30
Share

SettingsSettingsSettings
Sample Quiz For Testing - Quiz

Sample for testing formatting.


Questions and Answers
  • 1. 

    Given: 5. enum Towns1{NY, LA, SF} 6. 7. public class DeclareEnum { 8. 9. enum Towns2{NY, LA, SF}; 10. 11. public static void main(String [] args) { 12. enum Towns3{NY, LA, SF}; 13. } 14. } What is the result?

    • A.

      The code compiles.

    • B.

      Compilation fails due to an error on line 5.

    • C.

      Compilation fails due to an error on line 9.

    • D.

      Compilation fails due to an error on line 12.

    • E.

      Compilation fails due to errors on lines 5 and 12.

    Correct Answer
    D. Compilation fails due to an error on line 12.
    Explanation
    An enum may NOT be declared in a method. Reference
    JLS 3.0, 8.9. Objective 1.1

    Rate this question:

  • 2. 

    Given three different source files: 1. package com.sun2; 2. public enum Seasons {SUMMER, FALL, WINTER, SPRING } And: 1. import com.sun2.Seasons; 2. class Enum3a { 3. Seasons s = Seasons.FALL; 4. } And: 1. import com.sun2.*; 2. class Enum3b { 3. Seasons s = Seasons.FALL; 4. } Which is true?

    • A.

      Both classes, Enum3a and Enum3b, will compile.

    • B.

      Neither class, Enum3a nor Enum3b, will compile.

    • C.

      Class Enum3a will compile, class Enum3b will NOT compile.

    • D.

      Class Enum3b will compile, class Enum3a will NOT compile.

    Correct Answer
    A. Both classes, Enum3a and Enum3b, will compile.
    Explanation
    Option A is correct. An enum can be imported. Reference JLS 3.0, 8.9. Objective 1.1

    Rate this question:

Quiz Review Timeline +

Our quizzes are rigorously reviewed, monitored and continuously updated by our expert board to maintain accuracy, relevance, and timeliness.

  • Current Version
  • Dec 31, 2012
    Quiz Edited by
    ProProfs Editorial Team
  • May 11, 2009
    Quiz Created by
    Terogers
Back to Top Back to top
Advertisement