Java Exam 7 November 2014

10 Questions | Total Attempts: 47

SettingsSettingsSettings
Please wait...
Java Exam 7 November 2014


Questions and Answers
  • 1. 
    Which statement(s) are true? (Choose all that apply.)
    • A. 

      Cohesion is the OO principle most closely associated with hiding implementation details

    • B. 

      Cohesion is the OO principle most closely associated with making sure that classes know about other classes only through their APIs

    • C. 

      Cohesion is the OO principle most closely associated with making sure that a class is designed with a single, well-focused purpose

    • D. 

      Cohesion is the OO principle most closely associated with allowing a single object to be seen as having many types

  • 2. 
    Given:What is the result? 
    • A. 

      -124

    • B. 

      -134

    • C. 

      -424

    • D. 

      -434

    • E. 

      -444

    • F. 

      Compilation fails

  • 3. 
    Given:What is the result? 
    • A. 

      Furry bray

    • B. 

      Stripes bray

    • C. 

      Furry generic noise

    • D. 

      An exception is thrown at runtime

    • E. 

      Stripes generic noice

    • F. 

      Compilation fails

  • 4. 
    Given:What is the result? 
    • A. 

      5 7

    • B. 

      5 8

    • C. 

      8 7

    • D. 

      8 8

    • E. 

      Compilation fails

    • F. 

      An exception is thrown at runtime

  • 5. 
    Given:
    • A. 

      2

    • B. 

      4

    • C. 

      An exception is thrown at runtime

    • D. 

      Compilation fails due to an error on line 4

    • E. 

      Compilation fails due to an error on line 5

    • F. 

      Compilation fails due to an error on line 6

    • G. 

      Compilation fails due to an error on line 7

  • 6. 
    Which are true? (Choose all that apply.)
    • A. 

      It is appropriate to use assertions to validate arguments to methods marked public

    • B. 

      It is appropriate to catch and handle assertion errors

    • C. 

      It is NOT appropriate to use assertions to validate command-line arguments

    • D. 

      It is appropriate to use assertions to generate alerts when you reach code that should not be reachable

    • E. 

      It is NOT appropriate for assertions to change a program’s state

  • 7. 
    Given:What is the result? (Choose all that apply.) 
    • A. 

      Compilation succeeds

    • B. 

      Compilation fails due to an error on line 8

    • C. 

      Compilation fails due to an error on line 10

    • D. 

      Compilation fails due to an error on line 12

    • E. 

      Compilation fails due to an error on line 14

  • 8. 
    Which are true about a static nested class? (Choose all that apply.)
    • A. 

      You must have a reference to an instance of the enclosing class in order to instantiate it

    • B. 

      It does not have access to non-static members of the enclosing class

    • C. 

      Its variables and methods must be static

    • D. 

      If the outer class is named MyOuter, and the nested class is named MyInner, it can be instantiated using new MyOuter.MyInner();

    • E. 

      It must extend the enclosing class

  • 9. 
    Given:Which could be used to create an appropriate catch block? (Choose all that apply.) 
    • A. 

      ClassCastException

    • B. 

      IllegalStateException

    • C. 

      IllegalStateException

    • D. 

      IllegalStateException

    • E. 

      ExceptionInInitializerError

    • F. 

      ArrayIndexOutOfBoundsException

  • 10. 
    Given:What is the result? 
    • A. 

      Compilation fails

    • B. 

      Button key lint nickel nickel lint key button

    • C. 

      Nickel button key lint button key lint nickel

    • D. 

      Nickel button key lint nickel button key lint

    • E. 

      Nickel button key lint nickel lint key button

    • F. 

      An exception is thrown at runtime

Back to Top Back to top