មជ្ឈមណ្ឌលកូរ៉េ សហ្វវែរ អេច អ ឌី

Slides:



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

Chapter 1 Inheritance University Of Ha’il.
INHERITANCE BASICS Reusability is achieved by INHERITANCE
Module 8 “Polymorphism and Inheritance”. Outline Understanding Inheritance Inheritance Diagrams Constructors in Derived Classes Type Compatibility Polymorphism.
1 Chapter 6: Extending classes and Inheritance. 2 Basics of Inheritance One of the basic objectives of Inheritance is code reuse If you want to extend.
Objectives Introduction to Inheritance and Composition (Subclasses and SuperClasses) Overriding (and extending), and inheriting methods and constructors.
1 Topic 10 Abstract Classes “I prefer Agassiz in the abstract, rather than in the concrete.”
CS 2511 Fall  Abstraction Abstract class Interfaces  Encapsulation Access Specifiers Data Hiding  Inheritance  Polymorphism.
Like our natural language. Designed to facilitate the expression and communication ideas between people and computer Like our natural language. Designed.
Inheritance using Java
Introduction to Object Oriented Programming. Object Oriented Programming Technique used to develop programs revolving around the real world entities In.
1 Object-Oriented Software Engineering CS Interfaces Interfaces are contracts Contracts between software groups Defines how software interacts with.
Object Oriented Programming: Java Edition By: Samuel Robinson.
Specialization and Inheritance Chapter 8. 8 Specialization Specialized classes inherit the properties and methods of the parent or base class. A dog is.
Features of Object Oriented Programming Lec.4. ABSTRACTION AND ENCAPSULATION Computer programs can be very complex, perhaps the most complicated artifact.
Inheritance, Abstract & Interface Pepper With help from and
JAVA WORKSHOP SESSION – 3 PRESENTED BY JAYA RAO MTech(CSE) NEWTON’S INSTITUTE OF ENGINEERING 1.
Inheritance in the Java programming language J. W. Rider.
Programming using C# for Teachers Introduction to Objects Reference Types Functions of Classes Attributes and Types to a class LECTURE 2.
1 Abstract Classes “I prefer Agassiz in the abstract, rather than in the concrete.” CS Computer Science II.
RIT Computer Science Dept. Goals l Inheritance l Modifiers: private, public, protected l Polymorphism.
Peyman Dodangeh Sharif University of Technology Fall 2014.
1 COSC2007 Data Structures II Chapter 9 Class Relationships.
Application development with Java Lecture 21. Inheritance Subclasses Overriding Object class.
Topics Inheritance introduction
Access Specifier. Anything declared public can be accessed from anywhere. Anything declared private cannot be seen outside of its class. When a member.
AD Lecture #1 Object Oriented Programming Three Main Principles 1 Inheritance Encapsulation Polymorphism.
Object orientation and Packaging in Java Object Orientation and Packaging Introduction: After completing this chapter, you will be able to identify.
1 C# - Inheritance and Polymorphism. 2 1.Inheritance 2.Implementing Inheritance in C# 3.Constructor calls in Inheritance 4.Protected Access Modifier 5.The.
Java Inheritance in Java. Inheritance Inheritance is a mechanism in which one object acquires all the properties and behaviors of parent object. The idea.
Terms and Rules II Professor Evan Korth New York University (All rights reserved)
POLYMORPHISM Chapter 6. Chapter Polymorphism  Polymorphism concept  Abstract classes and methods  Method overriding  Concrete sub classes and.
BY:- TOPS Technologies
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.
Comp1004: Object Oriented Design I Abstract Classes and Interfaces.
Geoff Holmes and Bernhard Pfahringer COMP206-08S General Programming 2.
Java Programming Fifth Edition Chapter 9 Introduction to Inheritance.
Advanced Programming in Java
Modern Programming Tools And Techniques-I
Lecture 12 Inheritance.
Object-oriented Programming in Java
Objects as a programming concept
Inheritance.
Inheritance "Question: What is the object oriented way of getting rich? Answer: Inheritance.“ “Inheritance is new code that reuses old code. Polymorphism.
Object Oriented Analysis and Design
Chapter 10 Thinking in Objects
OOP’S Concepts in C#.Net
More on Classes & Arrays
null, true, and false are also reserved.
Interface.
Interfaces.
Advanced Programming Behnam Hatami Fall 2017.
Topic 10 Abstract Classes “I prefer Agassiz in the abstract,
METHOD OVERRIDING in JAVA
Inheritance Inheritance is a fundamental Object Oriented concept
Method Overriding in Java
Topic 10 Abstract Classes “I prefer Agassiz in the abstract,
Chapter 9 Carrano Chapter 10 Small Java
មជ្ឈមណ្ឌលកូរ៉េ សហ្វវែរ អេច អ ឌី
Assessment – Java Basics: Part 2
មជ្ឈមណ្ឌលកូរ៉េ សហ្វវែរ អេច អ ឌី
Chapter 11 Inheritance and Encapsulation and Polymorphism
Topics OOP Review Inheritance Review Abstract Classes
មជ្ឈមណ្ឌលកូរ៉េ សហ្វវែរ អេច អ ឌី
មជ្ឈមណ្ឌលកូរ៉េ សហ្វវែរ អេច អ ឌី
មជ្ឈមណ្ឌលកូរ៉េ សហ្វវែរ អេច អ ឌី
Inheritance Lakshmish Ramaswamy.
មជ្ឈមណ្ឌលកូរ៉េ សហ្វវែរ អេច អ ឌី
មជ្ឈមណ្ឌលកូរ៉េ សហ្វវែរ អេច អ ឌី
មជ្ឈមណ្ឌលកូរ៉េ សហ្វវែរ អេច អ ឌី
Presentation transcript:

មជ្ឈមណ្ឌលកូរ៉េ សហ្វវែរ អេច អ ឌី Korea Software HRD Center កម្មវិធីបង្រៀន Java Programming ជាភាសាខ្មែរ Online Java Training Course Advisor: Dr. Kim Tae Kyung www.kshrd.com.kh

ជំពូកទី ៧ Common Class www.kshrd.com.kh មេរៀនទី១៖ ​​ Inheritance មេរៀនទី២៖ Overriding មេរៀនទី៣៖ Polymorphism មេរៀនទី៣៖ Abstraction មេរៀនទី៣៖ Encapsulation មេរៀនទី៣៖ Interfaces មេរៀនទី៣៖ Packages www.kshrd.com.kh

មេរៀនទី១៖ ​​ Inheritance ១.១ .​ សេចក្តីផ្ដើម ១.២. ​​ IS-A Relationship ១.៣. HAS-A Relationship ១.៤. The instanceof Keyword www.kshrd.com.kh

១.១ .​ សេចក្តីផ្ដើម Inheritance: អនុញ្ញាតិឲ្យ Class មួយអាចទទួលយក​ Property​ (Fields, Methods) ទាំងអស់ពី Class មួយទៀត យកមកប្រើប្រាស់ ដោយមិនចាំបាច់សរសេរ Code ឡើងវិញតាមរយៈការប្រើ Keyword​ extends ឫ implements​ នៅ Class Declaration។ Class ដែលឲ្យគេយក Property មកប្រើត្រូវបានគេហៅថា (Super Class , Base Class ឫ Parent Class)។  Class ដែលទទួល Property ពីគេត្រូវបានគេហៅថា (Sub Class, Derived Class ឫ Child Class)។ Inheritance ជាលក្ខណៈពិសេសមួយក្នុងចំណោមលក្ខណៈពិសេសជាច្រើនទៀតរបស់ Object Oriented Programming។

១.១ .​ សេចក្តីផ្ដើម  Keyword Extends ប្រើសម្រាប់ Inherit ពី Class​ (Class Inheritance)។ Keyword Implements: ប្រើសម្រាប់ Inherit ពី Interface (Interface Inheritance)។ Inheritance​: មានលក្ខណៈ២ប្រភេទគឺ IS-A Relationship និង HAS-A Relationship ។ ​​ ​​​យើងអាច extend ពី Class បានតែមួយប៉ុណ្ណោះ។ តែយើងអាច implement ពី Interfaces មួយ ឫ ច្រើនបាន។ Inheritance ជាលក្ខណៈពិសេសមួយក្នុងចំណោមលក្ខណៈពិសេសជាច្រើនទៀតរបស់ Object Oriented Programming។

១.២. ​​ IS-A Relationship IS-A Relationship: គឺសំដៅ លើទំនាក់ទំនងរវាង Sub Class និង Super Class ដែល Object នៃ Sub Class គឺជាប្រភេទរបស់ Object នៃ Super Class នោះ ។ public interface Animal{ } public class Mammal implements Animal{ public class Reptile implements Animal{ public class Dog extends Mammal{ public class Animal{ } public class Mammal extends Animal{ public class Reptile extends Animal{ public class Dog extends Mammal{

១.២. ​​ IS-A Relationship Animal Mammal Dog Reptile ចំពោះ​ Object Oriented យើងអាចបាននិយាយបានថា: Animal គឺជា Super Class របស់ ​Mammal Class Animal គឺជា Super Class របស់ ​Reptile Class Animal គឺជា Super Class របស់ Dog Class ចំពោះ​ IS-A relationship យើងអាចបាននិយាយបានថា: Mammal IS-A Animal Reptile IS-A Animal Dog IS-A Mammal ដូចនេះ Dog IS-A ​ Animal Animal Mammal Dog Reptile

១.៣. HAS-A Relationship Animal Dog Legs HAS-A Relationship: គឺសំដៅលើទំនាក់ទំនងរវាង Class ពីរ ក្នុងការយក Instance Variable ដែលយោងទៅ Class មួយ មកប្រើក្នុង Class មួយទៀត ដោយមិនចាំបាច់សរសេរកូដច្រំដែរ ។ Animal Dog Legs IS-A HAS-A //Animal.java public class Animal {} //Legs.java public class Legs {} //Dog.java public class Dog extends Animal { private Legs dogLegs; }

១.៤. The instanceof Keyword Keyword instanceof: ​ គឺត្រូវបានគេប្រើដើម្បីត្រួតពិនិត្យ Object ណាមួយ ថាតើ វា​ជាប្រភេទនៃ Class ឫ Interface​ មួយណា ដោយធ្វើការប្រៀបធៀប Instance​ Object នោះជាមួយនឹង Class ឫ Interface ​ដែលផ្តល់ឲ្យហើយវាផ្តល់លទ្ធផលជា Boolean (true ឫ false)​។ interface Animal{} class Mammal implements Animal{} public class Dog extends Mammal{ public static void main(String args[]){ Mammal m = new Mammal(); Dog d = new Dog(); System.out.println(m instanceof Animal); System.out.println(d instanceof Mammal); System.out.println(d instanceof Animal); } លទ្ធផល៖ true ខាងក្រោមនេះគឺជាឩទាហរណ៏ នៃការប្រើប្រើស instanceof operator ដើម្បី ត្រួតពិនិត្យមើលថា តើ ថនិកសត្វ(Mammal) គឺពិតជា សត្វ(Animal) ហើយ ថាតើ សត្វឆ្កែ(dog) គឺពិតជា សត្វ(Animal) ។

សមាជិក ក្រុមអ្នកស្រាវជ្រាវ ក្រុមផលិតវីដេអូ vichea@rocketmail.com ល. ខេង ចាន់វិជ្ជា vichea@rocketmail.com ល. ឈុន បញ្ញារតន៍ chhunpanharath@gmail.com ល. ព្រាប វិទ្ធី Itpreap.vuthy@gmail.com ល. សែម ចិត្រា sabaychitra84@gmail.com ក. លីម សុខហេង lim.sokheng1@gmail.com ល. ហង្ស បូរី houngboreyrupp@gmail.com ល. ហួ ឈុនឡេង huochhunleng@yahoo.com ល. ឡៅ ស៊ុនឡេង sunlenglao@gmail.com.com ល. យ៉ូ វណ្ណរ៉ាវិទ្ធ ravuthz@gmail.com

មេរៀនបន្ទាប់ នឹងធ្វើការបង្ហាញពី ​ Overriding