OOP Aga private institute for computer science 5th grade

Slides:



Advertisements
Similar presentations
Final and Abstract Classes
Advertisements

INHERITANCE BASICS Reusability is achieved by INHERITANCE
Inheritance Inheritance Reserved word protected Reserved word super
Advanced Programming in Java
Sadegh Aliakbary Sharif University of Technology Fall 2010.
ITEC200 – Week03 Inheritance and Class Hierarchies.
More about classes and objects Classes in Visual Basic.NET.
Interface & Abstract Class. Interface Definition All method in an interface are abstract methods. Methods are declared without the implementation part.
Encapsulation, Inheritance & Interfaces CSE 115 Spring 2006 February 27, March 1 & 3, 2006.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
1 Chapter 6 Inheritance, Interfaces, and Abstract Classes.
CS 2511 Fall  Abstraction Abstract class Interfaces  Encapsulation Access Specifiers Data Hiding  Inheritance  Polymorphism.
Chapter 10 Classes Continued
©The McGraw-Hill Companies, Inc. Permission required for reproduction or display. 4 th Ed Chapter N - 1 Chapter 13 Polymorphism is-a relationships Interfaces.
OOP in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
Like our natural language. Designed to facilitate the expression and communication ideas between people and computer Like our natural language. Designed.
Inheritance using Java
Chapter 6 Class Inheritance F Superclasses and Subclasses F Keywords: super F Overriding methods F The Object Class F Modifiers: protected, final and abstract.
OOPs Object oriented programming. Based on ADT principles  Representation of type and operations in a single unit  Available for other units to create.
CSM-Java Programming-I Spring,2005 Objects and Classes Overview Lesson - 1.
Inheritance and Class Hierarchies Ellen Walker CPSC 201 Data Structures Hiram College.
Object Oriented Programming: Java Edition By: Samuel Robinson.
Chapter 2 Introducing Interfaces Summary prepared by Kirk Scott.
Chapter 3 Inheritance and Polymorphism Goals: 1.Superclasses and subclasses 2.Inheritance Hierarchy 3.Polymorphism 4.Type Compatibility 5.Abstract Classes.
8. Inheritance “Is-a” Relationship. Topics Creating Subclasses Overriding Methods Class Hierarchies Abstract Class Inheritance and GUIs The Timer Class.
Introduction to Java Chapter 7 - Classes & Object-oriented Programming1 Chapter 7 Classes and Object-Oriented Programming.
Inheritance. Inheritance - Introduction Idea behind is to create new classes that are built on existing classes – you reuse the methods and fields and.
OOPs Object oriented programming. Abstract data types  Representationof type and operations in a single unit  Available for other units to create variables.
Lecture 21 - Abstract Classes and Interface. Example Figure –Rectangle –Triangle Figure –Dimensions –Area.
Design Patterns Software Engineering CS 561. Last Time Introduced design patterns Abstraction-Occurrence General Hierarchy Player-Role.
Coming up: Inheritance
JAVA INTRODUCTION. What is Java? 1. Java is a Pure Object – Oriented language 2. Java is developing by existing languages like C and C++. How Java Differs.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
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.
Classes, Interfaces and Packages
Access Specifier. Anything declared public can be accessed from anywhere. Anything declared private cannot be seen outside of its class. When a member.
YG - CS Concept of Encapsulation What is encapsulation? - data and functions/methods are packaged together in the class normally.
Author: DoanNX Time: 45’.  OOP concepts  OOP in Java.
Chapter 9: Continuing Classes By Matt Hirsch. Table Of Contents 1.Static Fields and Methods 2.Inheritance I. Recycle Code with Inheritance II. Overriding.
Software Construction Lab 05 Abstraction, Inheritance, and Polymorphism in Java.
JAVA ACCESS MODIFIERS. Access Modifiers Access modifiers control which classes may use a feature. A classes features are: - The class itself - Its member.
Geoff Holmes and Bernhard Pfahringer COMP206-08S General Programming 2.
Modern Programming Tools And Techniques-I
Abstract classes and interfaces
Advanced Programming in Java
Advanced Programming in Java
Sections Inheritance and Abstract Classes
OOP: Encapsulation &Abstraction
Objects as a programming concept
Final and Abstract Classes
03/10/14 Inheritance-2.
Chapter 3: Using Methods, Classes, and Objects
INTRODUCTION TO OBJECT-ORIENTED PROGRAMMING (OOP) & CONCEPTS
Packages, Interfaces & Exception Handling
Object Oriented Analysis and Design
Abstract classes and interfaces
null, true, and false are also reserved.
Interface.
Java Programming Language
Interfaces.
Advanced Programming Behnam Hatami Fall 2017.
Advanced Java Programming
Advanced Programming in Java
By Rajanikanth B OOP Concepts By Rajanikanth B
Abstract classes and interfaces
Final and Abstract Classes
Chapter 11 Inheritance and Encapsulation and Polymorphism
Topics OOP Review Inheritance Review Abstract Classes
មជ្ឈមណ្ឌលកូរ៉េ សហ្វវែរ អេច អ ឌី
Presentation transcript:

OOP Aga private institute for computer science 5th grade Lecturer : Srwa Mohammad

Abstraction Abstract class: is a class that cant be instantiated because they are incomplete classes, they only used to be super class for concrete subclass We can make a class or method abstract simply by using abstract keyword ex: public abstract void add(); Any class that contain an abstract method must be abstract class even it include (non-abstract) methods too. Note: Constructors and Static methods could never be an abstract.

Encapsulation Encapsulation is the bending together of code and data to keep both of them safe from out side interface and misuse For example private data and codes for an object cant be reached by any other parts of program without permission from that object. So we can say this object is encapsulated.

Interfaces In java we can only extend one class, but some times we need more than one super class in sub class in this situation we have to use interfaces. Concept of interface: concrete subclass can be inherited from only one class, but it also can use the useful contents from interfaces methods. Interface is like class but it can only contain abstract methods Any class that implements interface must define the interface method or must be an abstract class it self. To use the interface we use (implements) keyword

Packages Package: is a collection of related classes and interfaces providing access protection and namespace management Packages are useful for managing the complicity of applications, and to support software reusability. To handle group of related classes we use packages for example: for input data we use (java.util.Scanner) package

How to create and use a package? Package declaration statement should be the first statement in the file which contains the classes or interfaces. To use class of a package, use import statement to import classes of that package to your program. If there is multiple classes in a file, only 1 of them can be public, so only that public class can be accessed outside the package.

Package example package MyPack; public class math1 { public static double add(double a, double b) return a+b; } public class math2 public static double sub(double a, double b) return a-b;

package MyPack; public class math3 { public static double mult(double a, double b) return a*b; } public class math4 public static double div(double a, double b) return a/b;

//sub package imports objects in a package MyPack by a class called oopEx //using * means all classes in this package can be used import MyPack.*; public class oopEx { public static void main(String[]ags) double a=5; double b=10; System.out.println(math1.add(a,b)); System.out.println(math2.sub(a,b)); System.out.println(math3.mult(a,b)); System.out.println(math4.div(a,b)); }