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

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

    • Public
    • Protected
    • Package (aka default)
    • Private
Please wait...
Java Programming 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. 

    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:

  • 3. 

    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

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

  • 4. 

    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:

  • 5. 

    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:

  • 6. 

    Why is data abstraction important?

  • 7. 

    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)

  • 8. 

    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.

  • 9. 

    Mention the three forms of inheritance, and when each one is used.

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
Back to Top Back to top
Advertisement
×

Wait!
Here's an interesting quiz for you.

We have other quizzes matching your interest.