CIS 212 Test 1

Reviewed by Editorial Team
The ProProfs editorial team is comprised of experienced subject matter experts. They've collectively created over 10,000 quizzes and lessons, serving over 100 million users. Our team includes in-house content moderators and subject matter experts, as well as a global network of rigorously trained contributors. All adhere to our comprehensive editorial guidelines, ensuring the delivery of high-quality content.
Learn about Our Editorial Process
| By Xenonii
X
Xenonii
Community Contributor
Quizzes Created: 4 | Total Attempts: 992
| Attempts: 85
SettingsSettings
Please wait...
  • 1/9 Questions

    An abstract class is a class which

    • Doesn't have any implementation of methods
    • Has abstract methods but possibly some defined methods as well
    • Is only accessed from the same package
    • Has only implemented methods
    • None of the above
Please wait...
CIS Quizzes & Trivia
About This Quiz

This test evaluates knowledge on Java programming, focusing on abstract classes, access modifiers, method signatures, and the importance of data abstraction.


Quiz Preview

  • 2. 

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

    • Public

    • Protected

    • Package (aka default)

    • Private

    Correct Answer
    A. 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?

    • One

    • Two

    • Infinite

    • 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)?

    • For making composition possible

    • For data abstraction

    • For encapsulation and information hiding

    • For being able to use inheritance

    • None of the above

    Correct Answer
    A. 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?

    • When you extend a class

    • When you implement an interface

    • When you extend an abstract class

    • 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.

    • When a class calls the super constructors

    Correct Answer
    A. 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 (Updated): Mar 21, 2023 +

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.