CIS 212 Test 1

9 Questions | Total Attempts: 37

SettingsSettingsSettings
CIS Quizzes & Trivia

Test on CIS 212 including data abstraction, composition, and inheritance


Questions and Answers
  • 1. 
    An abstract class is a class which
    • A. 

      Doesn't have any implementation of methods

    • B. 

      Has abstract methods but possibly some defined methods as well

    • C. 

      Is only accessed from the same package

    • D. 

      Has only implemented methods

    • E. 

      None of the above

  • 2. 
    Which is the access modifier which makes an element accessible only from the same package or from subclasses
    • A. 

      Public

    • B. 

      Protected

    • C. 

      Package (aka default)

    • D. 

      Private

  • 3. 
    In Java how many abstract classes can I extend?
    • A. 

      One

    • B. 

      Two

    • C. 

      Infinite

    • D. 

      You cannot

  • 4. 
    Why is data abstraction important?
  • 5. 
    When seeing a method signature a lot of information is given. Explain what the following method signature tells the programmer:protected static String reverse(String s)
  • 6. 
    Why do we have different levels of access modifiers (public, protected, package, private)?
    • A. 

      For making composition possible

    • B. 

      For data abstraction

    • C. 

      For encapsulation and information hiding

    • D. 

      For being able to use inheritance

    • E. 

      None of the above

  • 7. 
    A method saveFile() throws a FileAlreadyExistsException. Write some code where you would call this method, and handle such an exception by telling the user what the error was and what he can do about it.
  • 8. 
    Mention the three forms of inheritance, and when each one is used.
  • 9. 
    What is composition?
    • A. 

      When you extend a class

    • B. 

      When you implement an interface

    • C. 

      When you extend an abstract class

    • D. 

      When an object A has a reference to another object B, and only A has a reference to it. Also A determines lifetime of B.

    • E. 

      When a class calls the super constructors