CIS 212 Test 2 - Polymorphism

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: 332 | Questions: 7
Please wait...
Question 1 / 7
0 %
0/100
Score 0/100
1. When using an object, the behaviour is defined by the

Explanation

When using an object, the behavior is defined by its actual type. This means that the object will exhibit the specific behaviors and functionalities that are defined in its actual class or type. The apparent type of an object refers to the type that is used to reference the object, but it does not determine the behavior of the object itself. Therefore, the actual type of an object is what ultimately defines its behavior.

Submit
Please wait...
About This Quiz
Polymorphism Quizzes & Trivia

This quiz tests knowledge on polymorphism, focusing on concepts like actual and apparent types, substitution principle, and how these influence object behavior and interface in object-oriented programming.

2. What is the actual type of an object?

Explanation

The actual type is determined during the construction of an object

Submit
3. An apparent type is always...

Explanation

Remember that a type includes itself as a supertype

Submit
4. When using an object, the interface is defined by the

Explanation

The interface of an object is defined by its apparent type, which is the type that is declared and known at compile-time. This is the type that determines which methods and properties can be accessed on the object. The actual type of an object, on the other hand, refers to the specific class or type that the object belongs to at runtime. While the actual type may be different from the apparent type in cases of inheritance or polymorphism, it does not affect the interface of the object. Therefore, the correct answer is apparent type.

Submit
5. Substitution principle means that

Explanation

The correct answer is that the substitution principle means that a subtype can be used wherever a supertype is expected without affecting the correctness of client code. This principle is a fundamental concept in object-oriented programming, where it allows for polymorphism and code reusability. By substituting a subtype for a supertype, we can write code that is more flexible and adaptable to different types of objects, without needing to modify the client code. This ensures that the client code will still work correctly, regardless of the specific subtype being used.

Submit
6. What is the apparent type of an object?

Explanation

E.g. Collection c = new Vector();
c has an apparent type as a Collection, but the actual type is Vector

Submit
7. When creating a subtype, Java cannot enforce some specification declared in some supertype. So in order for the subtype to be compliant with the spec, it should

Explanation

When creating a subtype in Java, it is important for the subtype to satisfy the postconditions and preconditions found in the specification of the supertype. This means that the subtype should adhere to the requirements and constraints set by the supertype, ensuring that it behaves correctly and consistently with the expected behavior. By satisfying the postconditions and preconditions, the subtype can ensure that it is compliant with the specification and can be used interchangeably with the supertype without causing any unexpected issues or errors.

Submit
View My Results

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
  • Jan 29, 2009
    Quiz Created by
    Xenonii
Cancel
  • All
    All (7)
  • Unanswered
    Unanswered ()
  • Answered
    Answered ()
When using an object, the behaviour is defined by the
What is the actual type of an object?
An apparent type is always...
When using an object, the interface is defined by the
Substitution principle means that
What is the apparent type of an object?
When creating a subtype, Java cannot enforce some specification...
Alert!

Advertisement