Unit 9: Inheritance Flashcards
Abstraction
The process of simplifying complex systems by focusing on essential features while hiding unnecessary details. It allows programmers to work with high-level concepts without worrying about implementation specifics.
Classes
User-defined data types in object-oriented programming. They serve as blueprints for creating objects by defining their attributes and methods.
Creating Superclasses and Subclasses
Involves designing and implementing relationships between classes in an object-oriented program. Superclasses provide common attributes and behaviors that can be inherited by subclasses, allowing for code reuse and organization.
Data Structures
Ways to organize, store, and manipulate data efficiently. They provide different methods of accessing, inserting, deleting, or searching for data elements based on specific requirements.
Diamond Problem
Refers to an issue that arises in multiple inheritance when two superclasses share a common superclass, resulting in ambiguity for subclasses on which superclass’s method to use.
Instance Variables
Variables declared within a class but outside any method. They hold unique values for each instance (object) of the class and define the state or characteristics of an object.
Object-Oriented Programming
A programming paradigm that organizes code into objects, which are instances of classes. It focuses on creating reusable and modular code by encapsulating data and behavior together.
Static Typing
A programming language feature that requires variables to be declared with their data types before they can be used. It helps catch errors at compile-time by enforcing type compatibility.
Subclasses
Classes that inherit properties and behaviors from superclasses. They can add additional attributes or override existing ones to create specialized versions of the superclass.
Superclasses
Refer to classes that other classes inherit from. They contain common attributes and behaviors that can be shared by multiple subclasses.
The Object Superclass
The root class in Java and many other object-oriented programming languages. All classes are derived from this superclass either directly or indirectly.
Constructors
Special methods within classes that are used to initialize objects when they are created. They have the same name as the class and are called automatically when an object is instantiated.
Inheritance Hierarchy
Represents the relationship between classes where one class inherits properties and behaviors from another class. It forms a hierarchical structure with parent and child classes.
Method Signature
Refers to the unique combination of a method’s name and its parameter types. It helps distinguish one method from another.
super keyword
Used in Java to refer to the superclass of a subclass. It allows access to the superclass’s methods, constructors, and instance variables.
extends SuperClassName
This keyword is used in object-oriented programming to establish an inheritance relationship between classes. It allows a subclass to inherit properties and behaviors from a superclass.
Inheritance
A concept in object-oriented programming where a class inherits the properties and behaviors of another class. It allows for code reuse and promotes the creation of hierarchical relationships between classes.
Methods
Functions defined within a class that perform specific tasks or actions when called upon by an object. They can manipulate data, interact with other objects, or return values.
Polymorphism
Refers to the ability of objects to take on multiple forms or have multiple types. In programming, it allows different objects to be treated as instances of a common superclass, enabling flexibility and extensibility.
Superclass
Also known as a parent class or base class, is a class that is extended by another class (subclass). It provides common attributes and behaviors that can be inherited by its subclasses.
area() method
A function defined within a class that calculates and returns the area of an object, such as a shape or figure.
extends
In Java, this keyword is used to create a subclass that inherits properties and methods from a superclass. It establishes an “is-a” relationship between classes.
isEquivalent() method
A method used to compare two objects or values to determine if they are equivalent or equal in some way. It typically returns true if they are equivalent, and false otherwise.
Object class
A blueprint or template for creating objects in object-oriented programming. It defines the properties and behaviors that an object of that class will have.
Subclass
A class that inherits properties and behaviors from another class, called the superclass. It can add new features or modify existing ones.
@Override
Annotation used in Java to indicate that a method in a subclass is intended to override a method with the same name in its superclass. It helps ensure that the method signature and return type are correct.
Javadoc comments
Special comments in Java that begin with /** and end with */. They are used to generate documentation for classes, methods, and fields, making it easier for other developers (including yourself) to understand how to use them.
Overloading
Refers to defining multiple methods with the same name but different parameters within a single class. The methods must have different parameter lists or different types of parameters.
Overriding
Occurs when a subclass provides its own implementation of a method that is already defined in its superclass. The overridden method in the subclass replaces the implementation inherited from the superclass.
Public Methods
Functions or procedures in a class that can be accessed and called from anywhere in the program. They are accessible to all other classes and objects.
Area method
A technique used in computer science to calculate the size or complexity of an algorithm by counting the number of basic operations performed. It helps determine the efficiency and performance of an algorithm.
isEquivalent method
A function used in computer programming that compares two objects or values and determines if they are equal in terms of their properties or attributes. It returns true if they are equivalent and false otherwise.
Overriding
A subclass provides its own implementation of a method that is already defined in its superclass. The overridden method in the subclass replaces the implementation inherited from the superclass.
Quadrilateral Class
A general class in object-oriented programming that represents a four-sided polygon. It serves as the parent class for more specific types of quadrilaterals, such as rectangles, squares, and parallelograms.
Rectangle Class
A specific type of shape defined in object-oriented programming that represents a four-sided polygon with opposite sides being equal in length and all angles being right angles.
Hierarchy Tree
A graphical representation that illustrates the hierarchical relationship between different elements or entities. It organizes them into levels or layers based on their parent-child relationships.
Object
An instance of a class that encapsulates data and behavior. It represents a real-world entity or concept in the program.
Type Diagram
A visual representation that shows the relationships between different types of objects in a program. It helps programmers understand how classes and interfaces are related to each other.
Constructor
A special method within a class that is used to initialize objects of that class. It is called automatically when an object is created and helps set initial values for its attributes.
Dynamic Type
Refers to the actual type of an object at runtime. It may differ from its static (declared) type and is determined based on the specific instance assigned to it during program execution.
Method Calling
Refers to invoking or executing a method in Java code. It involves using the method’s name followed by parentheses and passing any required arguments inside those parentheses.
override
Refers to providing a different implementation for a method inherited from a superclass or interface in its subclass or implementing class respectively. It allows the subclass to customize the behavior of inherited methods.
Static Type
Refers to the declared type of a variable or expression at compile-time. It determines the set of operations that can be performed on the variable or expression.
equals()
Used to compare two objects for equality. It checks if the values of the objects are the same, rather than comparing their memory addresses.
hashCode()
Used in Java to generate a unique integer value representing an object’s identity. It is often overridden in classes when custom equality comparisons need to be made.
java.lang package
A built-in package in Java that provides fundamental classes and interfaces for the Java language. It includes classes such as String, Integer, and Math.
Object superclass
The root class in Java that all other classes inherit from. It provides basic functionality and methods that are common to all objects.
Properties
Characteristics or attributes of an object that define its state. They store data and can be accessed and modified by the object’s methods.
toString()
Used to convert an object into a string representation. It returns a string that represents the state of the object.