Java Inheritance, Polymorphism, and Object Methods

0.0(0)
Studied by 0 people
call kaiCall Kai
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
GameKnowt Play
Card Sorting

1/20

flashcard set

Earn XP

Description and Tags

Vocabulary flashcards covering access modifiers, inheritance, the Object class, polymorphism, dynamic binding, casting, and object cloning in Java.

21 Terms

1
New cards

Protected Access

An access modifier that allows a method or instance variable to be accessed by name inside its own class definition, inside any class derived from it, and inside the definition of any class in the same package.

2
New cards

Package Access

The default access level (also known as friendly access) assigned to an instance variable or method definition that has no modifier, restricting direct access by name strictly to classes within the same package.

3
New cards

Default Package

An unnamed package containing all classes in the current directory that do not belong to an explicitly specified package.

4
New cards
<p>Java Access Modifiers Summary Diagram</p>

Java Access Modifiers Summary Diagram

A visual summary of member access rules showing that public members (v1v1) are accessible everywhere; protected members (v2v2) are accessible within the package and to derived subclasses outside it; package-access members (v3v3) are accessible only within the package; and private members (v4v4) are accessible solely within the defining class.

5
New cards

"Is a" Relationship

A relationship formed through inheritance where a derived class represents a specialized version of its base class, such as an HourlyEmployee being an Employee.

6
New cards

Composition

A "has a" relationship where a more complex class is constructed by including an instance variable of another class type, such as an Employee class containing a Date instance variable named hireDate.

7
New cards

super Keyword

A keyword used within a derived class method definition, followed by a dot, to invoke the base class version of an overridden method from its direct parent class.

8
New cards

Object Class

The ultimate ancestor of every class in Java, defined in the automatically imported java.lang package, ensuring every object is of type Object.

9
New cards

Overridden equals Method

A method with the signature public boolean equals(Object otherObject) that verifies the parameter is non-null, checks that getClass() matches exactly, type casts the parameter to the specific class, and compares instance variables.

10
New cards

getClass() Method

A final method inherited from the Object class that returns a representation only of the exact class used with new to instantiate the object, allowing precise class equality comparisons with == or !=.

11
New cards

instanceof Operator

A binary operator that returns true if the tested object is an instance of the specified class or an instance of any descendent class of that class.

12
New cards

Polymorphism

One of the three central OOP mechanisms (along with encapsulation and inheritance) that allows a single method name to have multiple meanings via late binding.

13
New cards

Early Binding

The process of associating a method definition with a method invocation at compile time.

14
New cards

Late Binding (Dynamic Binding)

The process of associating a method definition with its invocation at run time when the method is called; Java applies late binding to all methods except private, final, and static methods.

15
New cards

Static Binding

A compile-time association of a method definition based on the declared type of the variable naming the object, used by Java for private, final, and static methods.

16
New cards

final Modifier

A modifier indicating that a method cannot be overridden in a derived class (permitting early binding) or that a class cannot be extended as a base class.

17
New cards

Upcasting

The assignment of an object of a derived class to a variable of its base class or any of its ancestor classes.

18
New cards

Downcasting

An explicit type cast from a base class type to a derived class type (or from an ancestor class to a descendent class), which risks a run-time error if the object is not an instance of the specified type.

19
New cards

clone Method

A parameterless method inherited from the Object class (declared as protected Object clone()) intended to be overridden with a public method that returns a deep copy of the calling object.

20
New cards

Covariant Return Type

A feature introduced in Java version 5.05.0 permitting an overriding method definition to change its return type to a descendent class of the return type declared in the ancestor method.

21
New cards

Limitation of Copy Constructors

The architectural limitation wherein copy constructors cannot create polymorphic copies when invoked through base class references, slicing derived objects into plain base objects unlike the clone method.