CIS 212 Test 1

Approved & Edited by ProProfs Editorial Team
The editorial team at ProProfs Quizzes consists of a select group of subject experts, trivia writers, and quiz masters who have authored over 10,000 quizzes taken by more than 100 million users. This team includes our in-house seasoned quiz moderators and subject matter experts. Our editorial experts, spread across the world, are rigorously trained using our comprehensive guidelines to ensure that you receive the highest quality quizzes.
Learn about Our Editorial Process
| By Xenonii
X
Xenonii
Community Contributor
Quizzes Created: 4 | Total Attempts: 990
Questions: 9 | Attempts: 83

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

    Correct Answer
    B. Has abstract methods but possibly some defined methods as well
    Explanation
    An abstract class is a class that cannot be instantiated and is meant to be extended by other classes. It may have abstract methods, which are methods without any implementation that must be implemented by the subclasses, and it may also have defined methods, which are methods with a complete implementation. Therefore, an abstract class can have a combination of abstract and defined methods.

    Rate this question:

  • 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

    Correct Answer
    B. Protected
    Explanation
    The access modifier "protected" makes an element accessible only from the same package or from subclasses. This means that any class within the same package can access the protected element, as well as any subclass of the class that contains the protected element, regardless of whether the subclass is in the same package or not. This access modifier provides a level of encapsulation and restricts access to the protected element from classes outside the package or unrelated subclasses.

    Rate this question:

  • 3. 

    In Java how many abstract classes can I extend?

    • A.

      One

    • B.

      Two

    • C.

      Infinite

    • D.

      You cannot

    Correct Answer
    A. One
    Explanation
    In Java you can only extend (inherit) one class, including abstract classes.

    Rate this question:

  • 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

    Correct Answer
    C. For encapsulation and information hiding
    Explanation
    Some elements of a class need to be part of the public interface, however you might want some of the elements to be hidden from certain classes, and not hidden from others. So the programmer has fine control on what is visible to whom

    Rate this question:

  • 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

    Correct Answer
    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.
    Explanation
    Composition refers to a design pattern in object-oriented programming where one object, A, has a reference to another object, B. In this pattern, only object A has a reference to object B, and it also determines the lifetime of object B. This means that if object A is destroyed or goes out of scope, object B will also be destroyed. Composition is commonly used to create complex objects by combining simpler objects, allowing for code reuse and modularity.

    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
  • Mar 21, 2023
    Quiz Edited by
    ProProfs Editorial Team
  • Dec 03, 2008
    Quiz Created by
    Xenonii

Related Topics

Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.