Abstract Classes AKEEL AHMED.

Slides:



Advertisements
Similar presentations
OOP Abstraction Classes Class Members: Properties & Methods Instance (object) Encapsulation Interfaces Inheritance Composition Polymorphism Using Inheritance.
Advertisements

METHOD OVERRIDING 1.Sub class can override the methods defined by the super class. 2.Overridden Methods in the sub classes should have same name, same.
ITF11006.NET Inheritance. Classes and Inheritance Constructors and Inheritance Modifiers Interfaces Operators.
Chapter 1 OO using C++. Abstract Data Types Before we begin we should know how to accomplish the goal of the program We should know all the input and.
8.1 Classes & Inheritance Inheritance Objects are created to model ‘things’ Sometimes, ‘things’ may be different, but still have many attributes.
© 2006 Pearson Addison-Wesley. All rights reserved9 A-1 Chapter 9 Advanced Java Topics CS102 Sections 51 and 52 Marc Smith and Jim Ten Eyck Spring 2007.
Inheritance. Types of Inheritance Implementation inheritance means that a type derives from a base type, taking all the base type’s member fields and.
1 Classes- Inheritance Multiple Inheritance It is possible to derive a new class from more than one base class. This is called Multiple Inheritance. Under.
Chapter 15 – Inheritance, Virtual Functions, and Polymorphism
Polymorphism. Introduction ‘one name multiple forms’ Implemented using overloaded functions and operators Early binding or static binding or static linking.
(C) 2010 Pearson Education, Inc. All rights reserved. Java™ How to Program, 8/e.
Lecture 9 Polymorphism Richard Gesick.
Unit IV Unit IV: Virtual functions concepts, Abstracts classes & pure virtual functions. Virtual base classes, Friend functions, Static functions, Assignment.
Inheritance in the Java programming language J. W. Rider.
OOP: Encapsulation,Abstraction & Polymorphism. What is Encapsulation Described as a protective barrier that prevents the code and data being randomly.
Copyright 2006 Oxford Consulting, Ltd1 February Polymorphism Polymorphism Polymorphism is a major strength of an object centered paradigm Same.
Class Relationships And Reuse Interlude 4 Data Structures and Problem Solving with C++: Walls and Mirrors, Frank Carrano, © 2012.
Interfaces Chapter 9. 9 Creating Interfaces An interface is a contract. Every class that implements the interface must provide the interface’s defined.
Introduction to Object-Oriented Programming Lesson 2.
Method Overriding Remember inheritance: when a child class inherits methods, variables, etc from a parent class. Example: public class Dictionary extends.
© 2007 Lawrenceville Press Slide 1 Chapter 9 Inheritance  One class is an extension of another.  Allows a class to define a specialized type of an existing.
Inheritance Inheritance is the process of extending the functionality of a class by defining a new class that inherit,all the features of extending class.
Quick Review of OOP Constructs Classes:  Data types for structured data and behavior  fields and methods Objects:  Variables whose data type is a class.
Presented by Ted Higgins, SQL Server DBA An Introduction to Object – Oriented Programming.
1 C# - Inheritance and Polymorphism. 2 1.Inheritance 2.Implementing Inheritance in C# 3.Constructor calls in Inheritance 4.Protected Access Modifier 5.The.
Recap Introduction to Inheritance Inheritance in C++ IS-A Relationship Polymorphism in Inheritance Classes in Inheritance Visibility Rules Constructor.
Polymorphism and Virtual Functions One name many shapes behaviour Unit - 07.
CH10 Supplementary Material Prepared by Fatimah Alakeel Oct 2010.
COP INTERMEDIATE JAVA Inheritance, Polymorphism, Interfaces.
Polymorphism & Virtual Functions 1. Objectives 2  Polymorphism in C++  Pointers to derived classes  Important point on inheritance  Introduction to.
1 Inheritance One of the goals of object oriented programming is code reuse. Inheritance is one mechanism for accomplishing code reuse. It allows us to.
Inheritance Modern object-oriented (OO) programming languages provide 3 capabilities: encapsulation inheritance polymorphism which can improve the design,
Polymorphism in Methods
OOP: Encapsulation &Abstraction
Chapter 12 OOP: Polymorphism, Interfaces and Operator Overloading
Classes and Inheritance
2.7 Inheritance Types of inheritance
Polymorphism, Abstract Classes & Interfaces
Inheritance and Polymorphism
One class is an extension of another.
Class A { public : Int x; A()
CS212: Object Oriented Analysis and Design
Inheritance AKEEL AHMED.
Polymorphism & Virtual Functions
Array Array is a variable which holds multiple values (elements) of similar data types. All the values are having their own index with an array. Index.
Object Oriented Programming
Polymorphism Lec
Interfaces.
Lecture 23 Polymorphism Richard Gesick.
OOP’S Concepts in C#.Net
Inheritance, Polymorphism, and Interfaces. Oh My
Java Programming Language
Lecture 22 Inheritance Richard Gesick.
Virtual Functions Department of CSE, BUET Chapter 10.
Advanced Java Topics Chapter 9
Packages and Interfaces
Polymorphism CT1513.
Interfaces.
Polymorphism, Abstract Classes & Interfaces
Polymorphism Polymorphism
Abstract Classes Page
Java – Inheritance.
9: POLYMORPHISM Programming Technique II (SCSJ1023) Jumail Bin Taliba
Pointers Dr. Bhargavi Goswami Department of Computer Science
Java Inheritance.
Fundaments of Game Design
Chapter 9 Carrano Chapter 10 Small Java
Abstract Classes and Interfaces
Chapter 14 Abstract Classes and Interfaces
Chapter 11 Class Inheritance
Presentation transcript:

Abstract Classes AKEEL AHMED

Overview Sealed Classes Interface Polymorphism Static classes Abstract Classes Sealed Classes Interface Polymorphism Static classes

Abstract Classes C# allows both classes and functions to be declared abstract using the abstract keyword. You can't create an instance of an abstract class. An abstract member has a signature but no function body and they must be overridden in any non-abstract derived class. Abstract classes exist primarily for inheritance. Member functions, properties and indexers can be abstract. A class with one or more abstract members must be abstract as well. Static members can't be abstract.

Abstract Classes

Sealed Classes Sealed classes are the reverse of abstract classes. While abstract classes are inherited and are refined in the derived class, sealed classes cannot be inherited. You can create an instance of a sealed class. A sealed class is used to prevent further refinement through inheritance.

Sealed Classes

Interface An interface is a set of related functions that must be implemented in a derived class. Members of an interface are implicitly public and abstract. Interfaces are similar to abstract classes. First, both types must be inherited; second, you cannot create an instance of either.

Interface Although there are several differences as in the following; An Abstract class can contain some implementations but an interface can't. An Interface can only inherit other interfaces but abstract classes can inherit from other classes and interfaces. An Abstract class can contain constructors and destructors but an interface can't. An Abstract class contains fields but interfaces don't.

Interface (Example)

Interface (Example)

Polymorphism A Polymorphism is the ability to treat the various objects in the same manner. It is one of the significant benefits of inheritance. We can decide the correct call at runtime based on the derived type of the base reference. This is called late binding.

Polymorphism

Static classes A static class is declared using the "static" keyword. If the class is declared as static then the compiler never creates an instance of the class. All the member fields, properties and functions must be declared as static and they are accessed by the class name directly not by a class instance object.

Static classes