We think you have liked this presentation. If you wish to download it, please recommend it to your friends in any social system. Share buttons are a little bit lower. Thank you! Published by Kelly Turner Modified over 4 years ago.

Author:Akinolabar Shaktigrel
Language:English (Spanish)
Published (Last):23 September 2013
PDF File Size:19.91 Mb
ePub File Size:20.68 Mb
Price:Free* [*Free Regsitration Required]

Java: the complete reference, 7th edition, Herbert schildt, TMH. Understanding 2. OOP with Java, updated edition, T. Budd, Pearson education. L2 L2. L5 L5. Humans manage complexity through abstraction. For example, people do not think of a car as a set of tens of thousands of individual parts. They think of it as a welldefined object with its own unique behavior.

This abstraction allows people to use a car without being overwhelmed by the complexity of the parts that form the car. They can ignore the details of how the engine, transmission, and braking systems work. Instead they are free to utilize the object as a whole.

If no parent class is specified explicitly, the base class Object is implicitly inherited. All classes defined in Java, is a child of Object class, which provides minimal functionality guaranteed to e common to all objects. Should be overridden when the equals method is changed. This method is also often overridden. A new class is derived from an existing class: 1 existing class is called super-class 2 derived class is called sub-class A sub-class is a specialized version of its super-class: 1 has all non-private members of its super-class 2 may provide its own implementation of super-class methods Objects of a sub-class are a special kind of objects of a super-class.

A subclass is something constructed using inheritance, whether or not it satisfies the principle of substitutability. The two concepts are independent. Not all subclasses are subtypes, and at least in some languages you can construct subtypes that are not subclasses. The idea is that, declared a variable in one type may hold the value of different type.

Substitutability can occur through use of inheritance, whether using extends, or using implements keywords. Instances of the subclass must implement, through inheritance at least, all functionality defined for parent class. Defining new methods is not important for the argument. Thus, an instance of a child class can mimic the behavior of the parent class and should be indistinguishable from an instance of parent class if substituted in a similar situation.

A type B is considered to be a subtype of A if an instances of B can legally be assigned to a variable declared as of type A. The term subclass refers to inheritance mechanism made by extends keyword. Not all subclasses are subtypes. Subtypes can also be formed using interface, linking types that have no inheritance relationship. As the name implies, the child inherits characteristics of the parent i. Inheritance for Specialization Inheritance for Specification Inheritance for Construction Inheritance for Extension Inheritance for Limitation Inheritance for Combination One or many of these forms may occur in a single case.

Always creates a subtype, and the principles of substitutability is explicitly upheld. It is the most ideal form of inheritance. Two different mechanisms are provided by Java, interface and abstract, to make use of subclassification for specification. Subtype is formed and substitutability is explicitly upheld. Mostly, not used for refinement of its parent class, but instead is used for definitions of the properties provided by its parent. The parent class specifies some behavior, but does not implement the behavior Child class implements the behavior Similar to Java interface or abstract class When parent class does not implement actual behavior but merely defines the behavior that will be implemented in child classes Example, Java 1.

This type of inheritance is also widely used for code reuse purposes. It simplifies the construction of newly formed abstraction but is not a form of subtype, and often violates substitutability. Example is Stack class defined in Java libraries. Child modify the arguments or names of methods An example might be subclassing the idea of a Set from an existing List class. Child class is not a more specialized form of parent class; no substitutability L 4. Such subclasses are always subtypes, and substitutability can be used.

Example of this type of inheritance is done in the definition of the class Properties which is an extension of the class HashTable. Like subclassification for extension, this form of inheritance occurs most frequently when a programmer is building on a base of existing classes. Is not a subtype, and substitutability is not proper.

Example, you have an existing List data type, and you want a Stack Inherit from List, but override the methods that allow access to elements other than top so as to produce errors. Although the Java does not permit a subclass to be formed be inheritance from more than one parent class, several approximations to the concept are possible.

Example: Mouse and TouchPad and JoyStick Better solution, abstract out common parts to new parent class, and use subclassing for specialization. The child class is a special case of the parent class; in other words, the child class is a subtype of the parent class. The parent class defines behavior that is implemented in the child class but not in the parent class.

The child class makes use of the behavior provided by the parent class, but is not a subtype of the parent class. The child class modifies or overrides some of the methods of the parent class. The child class adds new functionality to the parent class, but does not change any inherited behavior. The child class restricts the use of some of the behavior inherited from the parent class. The child class and parent class are variants of each other, and the class-subclass relationship is arbitrary.

The child class inherits features from more than one parent class. This is multiple inheritance and will be the subject of a later chapter. These are 3 types: 1. Multi Level Inheritance 3. Solution: Java provides a third visibility modifier that helps in inheritance situations: protected L 6. It is illegal to declare a class as both abstract and final. Polymorphism: many different poly forms of objects that share a common interface respond differently when a method of that interface is invoked: 1 a super-class defines the common interface 2 sub-classes have to follow this interface inheritance , but are also permitted to provide their own implementations overriding A sub-class provides a specialized behaviors relying on the common elements defined by its super-class.

It is the type of the object being referenced, not the reference type, that determines which method is invoked Polymorphic references are therefore resolved at run-time, not during compilation; this is called dynamic binding Careful use of polymorphic references can lead to elegant, robust software designs L 7. When an overridden method is called from within the sub-class: 1 it will always refer to the sub-class method 2 super-class method is hidden L 7. Overriding Overloading deals with multiple methods in the same class with the same name but different signatures Overloading lets you define a similar operation in different ways for different data o Overriding deals with two methods, one in a parent class and one in a child class, that have the same signature Overriding lets you define a similar operation in different ways for different object types L 7.

A super-class may altogether leave the implementation details of a method and declare such a method abstract: abstract type name parameter-list ; Two kinds of methods: 1 concrete may be overridden by sub-classes 2 abstract must be overridden by sub-classes It is illegal to define abstract constructors or static methods. Goals Chapter 13 - Inheritance To learn about inheritance To understand how to inherit and override superclass methods To be able to invoke superclass constructors To learn about protected and package.

Senem Kumova Metin Modified lecture notes of Dr. What is the most important feature of Java? Java is a platform independent language. What do you mean by platform independence? Platform independence means that we can write and compile the java.

A general purpose Object Oriented programming language. Created by Sun Microsystems. It s a general purpose. Suppose that you have written a program. Polymorphism 1 Agenda What is and Why Polymorphism? Generally, polymorphism refers. What is difference between overloading and overriding? Appendix E Glossary of Object Oriented Terms abstract class: A class primarily intended to define an instance, but can not be instantiated without additional methods. When you need to find and fix a bug or have to understand a tricky piece of code that your coworker wrote, you.

Juan - ajuanp gmail. Object Oriented Design Kenneth M. Java 12 Weeks Topic Lecture No. Inheritance, overloading and overriding Recall with inheritance the behavior and data associated with the child classes are always an extension of the behavior and data associated with the parent class.

Permission is granted to print and copy this document for non-commercial distribution and exclusive use by instructors. Java Application Developer Certificate Program Competencies After completing the following units, you will be able to: Basic Programming Logic Explain the steps involved in the program development cycle.

Represent a user-created or defined data type a. Time to study in more depth the foundations of the language,. Multichoice Quetions 1. Atributes a. Classes are arranged in hierarchies sharing common. Sullivan, Ph. Welcome to Computer Science E! We will study fundamental data structures. All rights reserved. LAB4 Making Classes and Objects Objective The main objective of this lab is class creation, how its constructer creation, object creation and instantiation of objects.

We will use the definition pane to.


Java 2 Complete Ref – TMH

Slideshare uses cookies to improve functionality and performance, and to provide you with relevant advertising. If you continue browsing the site, you agree to the use of cookies on this website. See our User Agreement and Privacy Policy. See our Privacy Policy and User Agreement for details.



You can Check Computer Graphics of B. We provide B. Tech student with free of cost and it can download easily and without registration need. From the following B.


Inheritance: Basic concepts, access specifiers, usage of super key word, method overriding, final methods and classes, abstract classes, dynamic method dispatch, Object class. Classes and Objects: Concepts, methods, constructors, usage of static, access control, this key word, garbage collection, overloading, parameter passing mechanisms, nested classes and inner classes. Interfaces: Differences between classes and interfaces, defining an interface, implementing interface, variables in interface and extending interfaces. Strings: Exploring the String class, String buffer class, Command-line arguments. Library: Date class, Collection, Enumerations and Wrapper classes. UNIT-II 18 Periods Exception Handling: Concepts of Exception handling, types of exceptions, usage of try, catch, throw, throws and finally keywords, Built-in exceptions, creating own exception sub classes.


Java: the complete reference, 7th edition, Herbert schildt, TMH. Understanding 2. OOP with Java, updated edition, T. Budd, Pearson education. L2 L2. L5 L5. Humans manage complexity through abstraction.

Related Articles