Chapter 11

अब Quizwiz के साथ अपने होमवर्क और परीक्षाओं को एस करें!

Method that compares two Objects based on the values they hold:

*You can create a method similar to those you have created for many classes and give it an identifier such as areTheyEqual( ) *You can overload the Object class equals( ) method *You can override the Object class equals( ) method

Comparing abstract classes and interfaces

Abstract classes and interfaces are similar in that you cannot instantiate concrete objects from either one *Abstract classes differ from interfaces because abstract classes can contain nonabstract methods, but all methods within an interface must be abstract *A class can inherit from only one abstract superclass, but it can implement any number of interfaces

boolean equals(Object obj)

Indicates whether some object is equal to the parameter object

hash code

a calculated number used to identify an object

Class

a class defined in the java.lang package that is imported automatically into every Java program *Every Java class descends from the Object class

Abstract Class

a class from which no concrete objects can be instantiated, but which can serve as a basis for inheritance. *Abstract classes usually have one or more empty abstract methods *Contrast with concrete class

Anonymous Inner Class

a class that has no name and is defined inside another class

Abstract Methods

a method declared with the keyword abstract and that has no body *A subclass must override each base class abstract method

Nonabstract Methods

a method that is inherited

Concrete Class

a nonabstract class from which objects can be instantiated *Contrast with abstract class

Java ARchive (JAR) file

a package file format used to distribute java programs and resources

Effectively Final Variable

a variable whose values is assigned only once

Comparing abstract classes and interfaces (Interface)

all variables in an interface must be public, static, and final * an interface has no constructor and cannot be instantiated * all methods in an interface must be public, abstract, and nonstatic.

Interface

an alternative to multiple inheritance *looks much like a class, except that all of its methods (if any) are implicitly public and abstract, and all of its data items (if any) are implicitly public, static, and final *is a description of what a class does, but not how it is done; it declares method headers, but not the instructions within those methods *use the keyword implements

Lambda Expression

an expression that creates an object that implements a functional interface

Functional Interface

an interface that contains just one abstract method

void finalize( )

called by the garbage collector on an object when there are no more references to the object

void wait( )

causes the current thread to wait until another thread invokes either the notify( ) method or the notifyAll( ) method for this object

void wait (long timeout, int nanos)

causes the current thread to wait until another thread invokes the notify( ) or notifyAll( ) method for this object, or some other threat interrupts the current thread, or a certain amount of real time has elapsed

void wait (long timeout)

causes the current thread to wait until either another thread invokes the notify( ) method or the notifyAll( ) method for this object, or a specified amount of time has elapsed

Object clone( )

creates and returns a copy of this object

Collision

describes a class naming conflict

Overriding equals( )

determine if the equals( ) argument is the same object as the calling object by using a comparison such as obj == this, and return true if it is *return false if the Object argument is null *return false if the calling and argument objects are not the same class *cast the Object argument to the same type as the calling object only if they are the same class *You should override the hashCode( ) method as well, because equals objects should have equal hash codes

Abstract Declarations

if you declare a class to be abstract, each of its methods can be abstract or not *If you declare a method to be abstract, you also must declare its class to be abstract

Lambda Operator

operator used in a lambda expression that is composed of a minus sign and greater-than sign

Ad-Hoc Polymorphism

polymorphism that occurs when a single method name can be used with a variety of data types because various implementations exist *Another name for method overloading

int hashCode( )

returns a hash code value for the object

String toString( )

returns a string representation of the object

Class<?> getClass( )

returns the class to which this object belongs at run time

Dynamic Method Binding

the ability of an application to select the correct subclass method when the program executes

Late Method Binding

the ability of an application to select the correct subclass method when the program executes

Multiple Inheritance

the capability to inherit from more than one class *Java does not support multiple inheritance

Virtual Class

the name given to an abstract class in some other programming languages, such as C++

Static (Fixed) Method Binding

the opposite of dynamic method binding *Occurs when a subclass method is selected while the program compiles rather than while it is running

Pure Polymorphism or Inclusion Polymorphism

the situation in which a single method implementation can be used with a variety of related objects because they are objects of subclasses of the parameter type

Default Package

the unnamed package in which a class is placed if no package is a specified

Comparing abstract classes and interfaces (Abstract Class)

there are no restrictions on variables in an abstract class *an abstract class's constructor is invoked when a child class object is instantiated *there are no restrictions on methods in an abstract class although an abstract class frequently contains one or more abstract methods

void notify( )

wakes up a single thread that is waiting on this object's monitor

void notifyAll( )

wakes up all threats that are waiting on this object's monitor


संबंधित स्टडी सेट्स

Biocomplexity - Week 1 revision quiz = the complexity of life

View Set

EMT Basic Quiz Bleeding Chapter 25

View Set

Chapter 5 Plate Tectonics Section 5 Plate Tectonics

View Set

Impuesto a las ganancias Impuesto de emergencia, que recauda la nación en virtud de una ley, es directo, progresivo y de ejercicio (porque tiene en cuenta todo lo que sucede en un año calendario)

View Set

Quantitative Reasoning Module 9, Section 11.4 Homework

View Set

Alice programming chapter 1-3 terms/review

View Set

IB Biology: Unit 2.9 Photosynthesis

View Set