Object Oriented Programming_Chapter 3 (Two Lectures)
1- Let’s think on Inheritance
2- Let’s focus on Superclass’s Constructor
الكلية الجامعية للعلوم والتكنولوجيا - خان يونس
University college of science & technology
Object Oriented Programming_Chapter 4 (Two Lectures)
1- Let’s think on polymorphism
2- Let’s focus on Full Example
الكلية الجامعية للعلوم والتكنولوجيا - خان يونس
University college of science & technology
Object Oriented Programming_Lecture 3
Let’s think on fields of class
Visibility Modifiers and Accessor Methods
الكلية الجامعية للعلوم والتكنولوجيا - خان يونس
University college of science & technology
ملفات مساق البرمجة الهدفية (الشيئية) التي يتم تدريسها لطلبة بكالوريوس تكنولوجيا المعلومات وبكالوريوس تطوير نظم الحاسوب في الكلية الجامعية للعلوم والتكنولوجيا.
الملف يضم مفهوم الوراثة Inheritance
إعدادي وتدريسي
ملفات مساق البرمجة الهدفية (الشيئية) التي يتم تدريسها لطلبة بكالوريوس تكنولوجيا المعلومات وبكالوريوس تطوير نظم الحاسوب في الكلية الجامعية للعلوم والتكنولوجيا.
الملف يضم مفهوم الوراثة Polymorphism
إعدادي وتدريسي
ملفات مساق البرمجة الهدفية (الشيئية) التي يتم تدريسها لطلبة بكالوريوس تكنولوجيا المعلومات وبكالوريوس تطوير نظم الحاسوب في الكلية الجامعية للعلوم والتكنولوجيا.
الملف يضم مفاهيم:
Class
Object
إعدادي وتدريسي
chapter 1: Lecture 2
Let’s think on concept of Class and Object
- Concept of Objects and classes
- UML Class Diagram
الكلية الجامعية للعلوم والتكنولوجيا - خان يونس
University college of science & technology
Object Oriented Programming_Chapter 4 (Two Lectures)
1- Let’s think on polymorphism
2- Let’s focus on Full Example
الكلية الجامعية للعلوم والتكنولوجيا - خان يونس
University college of science & technology
Object Oriented Programming_Lecture 3
Let’s think on fields of class
Visibility Modifiers and Accessor Methods
الكلية الجامعية للعلوم والتكنولوجيا - خان يونس
University college of science & technology
ملفات مساق البرمجة الهدفية (الشيئية) التي يتم تدريسها لطلبة بكالوريوس تكنولوجيا المعلومات وبكالوريوس تطوير نظم الحاسوب في الكلية الجامعية للعلوم والتكنولوجيا.
الملف يضم مفهوم الوراثة Inheritance
إعدادي وتدريسي
ملفات مساق البرمجة الهدفية (الشيئية) التي يتم تدريسها لطلبة بكالوريوس تكنولوجيا المعلومات وبكالوريوس تطوير نظم الحاسوب في الكلية الجامعية للعلوم والتكنولوجيا.
الملف يضم مفهوم الوراثة Polymorphism
إعدادي وتدريسي
ملفات مساق البرمجة الهدفية (الشيئية) التي يتم تدريسها لطلبة بكالوريوس تكنولوجيا المعلومات وبكالوريوس تطوير نظم الحاسوب في الكلية الجامعية للعلوم والتكنولوجيا.
الملف يضم مفاهيم:
Class
Object
إعدادي وتدريسي
chapter 1: Lecture 2
Let’s think on concept of Class and Object
- Concept of Objects and classes
- UML Class Diagram
الكلية الجامعية للعلوم والتكنولوجيا - خان يونس
University college of science & technology
ملفات مساق البرمجة الهدفية (الشيئية) التي يتم تدريسها لطلبة بكالوريوس تكنولوجيا المعلومات وبكالوريوس تطوير نظم الحاسوب في الكلية الجامعية للعلوم والتكنولوجيا.
الملف يضم مفهوم مصفوفة الكائنات Array of Objects
إعدادي وتدريسي
oops concept in java | object oriented programming in javaCPD INDIA
object oriented programming is a key concept for the development of application in windows as well as web based application environment. oops concept maps real world through its concept of classes, objects, inheritance, polymorphism which help in making a robust application.
This slide is based on Object Oriented Programming Language. Here is some details about object and class. You can easily understand about object and class.
ملفات مساق البرمجة الهدفية (الشيئية) التي يتم تدريسها لطلبة بكالوريوس تكنولوجيا المعلومات وبكالوريوس تطوير نظم الحاسوب في الكلية الجامعية للعلوم والتكنولوجيا.
الملف يضم مفهوم مصفوفة الكائنات Array of Objects
إعدادي وتدريسي
oops concept in java | object oriented programming in javaCPD INDIA
object oriented programming is a key concept for the development of application in windows as well as web based application environment. oops concept maps real world through its concept of classes, objects, inheritance, polymorphism which help in making a robust application.
This slide is based on Object Oriented Programming Language. Here is some details about object and class. You can easily understand about object and class.
Object Oriented Programming in Java _lecture 1Mahmoud Alfarra
Introduction to OOP
Let’s start with the first set of concepts
What is Object-Oriented Programming ?
Procedural vs. Object-Oriented Programming
OO Programming Concepts
Detailed presentation on Inheritance and interfaces in JAVA. Presentation includes suitable example for better understanding the concepts such as Overriding in java and also keywords such as FINAL and SUPER.
Ohhh ok ok ok ok then i can be taken in my life and i am not able to enter the correct me if you are not able to see you in your eyes and sorry for the
Definition of classification
Basic principles of classification
Typical
How Does Classification Works?
Difference between Classification & Prediction.
Machine learning techniques
Decision Trees
k-Nearest Neighbors
What is Object-Oriented Programming ?
What classes, objects, methods ?
How to declare a class ?
How to use class to create an object?
How to declare methods in a class ?
What is a computer?
Computer Organization
Programming languages
Java Class Libraries
Typical Java development environment
Case Study: Unified Modeling Language
June 3, 2024 Anti-Semitism Letter Sent to MIT President Kornbluth and MIT Cor...Levi Shapiro
Letter from the Congress of the United States regarding Anti-Semitism sent June 3rd to MIT President Sally Kornbluth, MIT Corp Chair, Mark Gorenberg
Dear Dr. Kornbluth and Mr. Gorenberg,
The US House of Representatives is deeply concerned by ongoing and pervasive acts of antisemitic
harassment and intimidation at the Massachusetts Institute of Technology (MIT). Failing to act decisively to ensure a safe learning environment for all students would be a grave dereliction of your responsibilities as President of MIT and Chair of the MIT Corporation.
This Congress will not stand idly by and allow an environment hostile to Jewish students to persist. The House believes that your institution is in violation of Title VI of the Civil Rights Act, and the inability or
unwillingness to rectify this violation through action requires accountability.
Postsecondary education is a unique opportunity for students to learn and have their ideas and beliefs challenged. However, universities receiving hundreds of millions of federal funds annually have denied
students that opportunity and have been hijacked to become venues for the promotion of terrorism, antisemitic harassment and intimidation, unlawful encampments, and in some cases, assaults and riots.
The House of Representatives will not countenance the use of federal funds to indoctrinate students into hateful, antisemitic, anti-American supporters of terrorism. Investigations into campus antisemitism by the Committee on Education and the Workforce and the Committee on Ways and Means have been expanded into a Congress-wide probe across all relevant jurisdictions to address this national crisis. The undersigned Committees will conduct oversight into the use of federal funds at MIT and its learning environment under authorities granted to each Committee.
• The Committee on Education and the Workforce has been investigating your institution since December 7, 2023. The Committee has broad jurisdiction over postsecondary education, including its compliance with Title VI of the Civil Rights Act, campus safety concerns over disruptions to the learning environment, and the awarding of federal student aid under the Higher Education Act.
• The Committee on Oversight and Accountability is investigating the sources of funding and other support flowing to groups espousing pro-Hamas propaganda and engaged in antisemitic harassment and intimidation of students. The Committee on Oversight and Accountability is the principal oversight committee of the US House of Representatives and has broad authority to investigate “any matter” at “any time” under House Rule X.
• The Committee on Ways and Means has been investigating several universities since November 15, 2023, when the Committee held a hearing entitled From Ivory Towers to Dark Corners: Investigating the Nexus Between Antisemitism, Tax-Exempt Universities, and Terror Financing. The Committee followed the hearing with letters to those institutions on January 10, 202
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdfTechSoup
In this webinar you will learn how your organization can access TechSoup's wide variety of product discount and donation programs. From hardware to software, we'll give you a tour of the tools available to help your nonprofit with productivity, collaboration, financial management, donor tracking, security, and more.
Introduction to AI for Nonprofits with Tapp NetworkTechSoup
Dive into the world of AI! Experts Jon Hill and Tareq Monaur will guide you through AI's role in enhancing nonprofit websites and basic marketing strategies, making it easy to understand and apply.
The French Revolution, which began in 1789, was a period of radical social and political upheaval in France. It marked the decline of absolute monarchies, the rise of secular and democratic republics, and the eventual rise of Napoleon Bonaparte. This revolutionary period is crucial in understanding the transition from feudalism to modernity in Europe.
For more information, visit-www.vavaclasses.com
Palestine last event orientationfvgnh .pptxRaedMohamed3
An EFL lesson about the current events in Palestine. It is intended to be for intermediate students who wish to increase their listening skills through a short lesson in power point.
Honest Reviews of Tim Han LMA Course Program.pptxtimhan337
Personal development courses are widely available today, with each one promising life-changing outcomes. Tim Han’s Life Mastery Achievers (LMA) Course has drawn a lot of interest. In addition to offering my frank assessment of Success Insider’s LMA Course, this piece examines the course’s effects via a variety of Tim Han LMA course reviews and Success Insider comments.
2024.06.01 Introducing a competency framework for languag learning materials ...Sandy Millin
http://sandymillin.wordpress.com/iateflwebinar2024
Published classroom materials form the basis of syllabuses, drive teacher professional development, and have a potentially huge influence on learners, teachers and education systems. All teachers also create their own materials, whether a few sentences on a blackboard, a highly-structured fully-realised online course, or anything in between. Despite this, the knowledge and skills needed to create effective language learning materials are rarely part of teacher training, and are mostly learnt by trial and error.
Knowledge and skills frameworks, generally called competency frameworks, for ELT teachers, trainers and managers have existed for a few years now. However, until I created one for my MA dissertation, there wasn’t one drawing together what we need to know and do to be able to effectively produce language learning materials.
This webinar will introduce you to my framework, highlighting the key competencies I identified from my research. It will also show how anybody involved in language teaching (any language, not just English!), teacher training, managing schools or developing language learning materials can benefit from using the framework.
Unit 8 - Information and Communication Technology (Paper I).pdfThiyagu K
This slides describes the basic concepts of ICT, basics of Email, Emerging Technology and Digital Initiatives in Education. This presentations aligns with the UGC Paper I syllabus.
Francesca Gottschalk - How can education support child empowerment.pptxEduSkills OECD
Francesca Gottschalk from the OECD’s Centre for Educational Research and Innovation presents at the Ask an Expert Webinar: How can education support child empowerment?
4. Outlines
◉ Motivation
◉ What is Inheritance ?
◉ Types of Inheritance
◉ Superclasses and Subclasses
◉ Defining a Subclass
◉ "is-a" and the "has-a" relationship
Note: I have prepared this material Based on (Liang: “Introduction to Programming using Java”, 10’th edition, 2015)
◉ Are superclass’s Constructor Inherited?
◉ Overriding Methods in the Subclass
◉ Full Example
◉ Important Notes
6. o Suppose you will define classes to model circles, rectangles, and
triangles.
o These classes have many common features. What is the best way
to design these classes so to avoid redundancy?
The answer is to use inheritance.
Motivation
7. What is Inheritance ?
o Inheritance is a form of software reuse in which a new class is
created by absorbing an existing class's members and
embellishing them with new or modified capabilities.
P_Properties
P_ methods
Parent Class
C_Properties
C_methods
Child Class
This class has its
properties, methods
and that of its parent.
8. Types of Inheritance
Single Inheritance
When a Derived Class to
inherit properties and
behavior from a single Base
Class, it is called as single
inheritance.
Multi Level Inheritance
A derived class is created
from another derived class
is called Multi Level
Inheritance.
Hierarchical Inheritance
More than one derived class
are created from a single
base class, is called
Hierarchical Inheritance
9. Types of Inheritance
Hybrid Inheritance
Any combination of above
three inheritance (single,
hierarchical and multi level) is
called as hybrid inheritance.
Multiple Inheritance
Multiple inheritances allows
programmers to create classes
that combine aspects of
multiple classes and their
corresponding hierarchies.
10. Superclasses and
Subclasses
GeometricObject
-color: String
-filled: boolean
-dateCreated: java.util.Date
+GeometricObject()
+GeometricObject(color: String,
filled: boolean)
+getColor(): String
+setColor(color: String): void
+isFilled(): boolean
+setFilled(filled: boolean): void
+getDateCreated(): java.util.Date
+toString(): String
The color of the object (default: white).
Indicates whether the object is filled with a color (default: false).
The date when the object was created.
Creates a GeometricObject.
Creates a GeometricObject with the specified color and filled
values.
Returns the color.
Sets a new color.
Returns the filled property.
Sets a new filled property.
Returns the dateCreated.
Returns a string representation of this object.
Circle
-radius: double
+Circle()
+Circle(radius: double)
+Circle(radius: double, color: String,
filled: boolean)
+getRadius(): double
+setRadius(radius: double): void
+getArea(): double
+getPerimeter(): double
+getDiameter(): double
+printCircle(): void
Rectangle
-width: double
-height: double
+Rectangle()
+Rectangle(width: double, height: double)
+Rectangle(width: double, height: double
color: String, filled: boolean)
+getWidth(): double
+setWidth(width: double): void
+getHeight(): double
+setHeight(height: double): void
+getArea(): double
+getPerimeter(): double
11. o In Java, as in other object-oriented programming languages,
classes can be derived from other classes.
o The derived class (the class that is derived from another class)
is called a subclass.
o The class from which its derived is called the superclass.
Superclasses and Subclasses
12. o A subclass normally adds its own fields and methods.
o Therefore, a subclass is more specific than its superclass.
o Typically, the subclass exhibits the behaviors of its superclass
and additional behaviors that are specific to the subclass.
Superclasses and Subclasses
13. Direct & Indirect Superclasses
properties3
methods3 SubClass
properties1
methods1
Indirect
SuperClass
properties2
methods2 Direct
SuperClass
o The direct superclass is the superclass
from which the subclass explicitly
inherits.
o An indirect superclass is any class above
the direct superclass in the class
hierarchy.
14. o A subclass inherits from a superclass. You can also:
Add new properties
Add new methods
Override the methods of the superclass.
Defining a Subclass
16. Defining a Subclass
class Vehicle {
protected String model;
protected float price;
public Vehicle(String model, float price){
this.model = model;
this.price = price;
}
public String print(){
return "Model: "+model+"t Price: "+price;
}
public void setModel(String model){
this.model = model;
}
public String getModel(){
return model;
} // set and get of price
}
Vehicle
Class SuperClass
Car Class SubClass
17. Defining a Subclass
class Car extends Vehicle{
private int passengers;
public Car(String model, float price,int passengers){
super( model, price);
this.passengers = passengers;
}
public String print(){
return "Data is:n"+super.print()+
" # of passengers: "+passengers;
}
}
18. Defining a Subclass
public class VehicleProjectInheritance {
public static void main(String[] args) {
Car c = new Car("Honda", 455.0f, 4);
System.out.println(c.print());
}
}
19. "is-a" and the "has-a" relationship
o "Is-a" represents inheritance.
o In an "is-a" relationship, an object of a subclass can also be
treated as an object of its superclass.
o “Has–a” represents the encapsulation, i.e: The relation between
object and its members.
20. "is-a" and the "has-a" relationship
Vehicle
Class SuperClass
Car Class SubClass
Honda is a car &
Honda is a vehicle
Object of sub is also an object of super
25. Are superclass’s Constructor Inherited?
o No. They are not inherited.
o They are invoked explicitly or implicitly.
o Explicitly using the super keyword.
o A constructor is used to construct an instance of a class.
Unlike properties and methods, a superclass's constructors are
not inherited in the subclass.
26. Superclass’s Constructor Is Always Invoked
o A constructor may invoke an overloaded constructor or its
superclass’s constructor. If none of them is invoked explicitly,
the compiler puts super() as the first statement in the
constructor. For example,
public A(double d) {
// some statements
}
is equivalent to
public A(double d) {
super();
// some statements
}
public A() {
}
is equivalent to
public A() {
super();
}
27. Using the Keyword super
o The keyword super refers to the superclass of the class in
which super appears. This keyword can be used in two ways:
1. To call a superclass constructor
2. To call a superclass method
28. Constructor Chaining
o Constructing an instance of a class invokes all the superclasses’
constructors along the inheritance chain.
o This is known as constructor chaining.
29. public class Faculty extends Employee {
public static void main(String[] args) {
new Faculty();
}
public Faculty() {
System.out.println("(4) Faculty's no-arg constructor is invoked");
}
}
class Employee extends Person {
public Employee() {
this("(2) Invoke Employee’s overloaded constructor");
System.out.println("(3) Employee's no-arg constructor is invoked");
}
public Employee(String s) {
System.out.println(s);
}
}
class Person {
public Person() {
System.out.println("(1) Person's no-arg constructor is invoked");
}
}
Trace Execution
30. Overriding Methods in the Subclass
o A subclass inherits methods from a superclass. Sometimes it is
necessary for the subclass to modify the implementation of a
method defined in the superclass.
o This is referred to as method overriding.
public class Circle extends GeometricObject {
// Other methods are omitted
/** Override the toString method defined in GeometricObject */
public String toString() {
return super.toString() + "nradius is " + radius; }
}
31. Overriding vs. Overloading
public class Test {
public static void main(String[] args) {
A a = new A();
a.p(10);
a.p(10.0);
}
}
class B {
public void p(double i) {
System.out.println(i * 2);
}
}
class A extends B {
// This method overrides the method in B
public void p(double i) {
System.out.println(i);
}
}
public class Test {
public static void main(String[] args) {
A a = new A();
a.p(10);
a.p(10.0);
}
}
class B {
public void p(double i) {
System.out.println(i * 2);
}
}
class A extends B {
// This method overloads the method in B
public void p(int i) {
System.out.println(i);
}
}
32. Overriding vs. Overloading
o The example above show the differences between overriding
and overloading.
o In (a), the method p(double i) in class A overrides the same
method in class B.
o In (b), the class A has two overloaded methods: p(double i) and
p(int i).
o The method p(double i) is inherited from B.
34. Full Example
o Constructing an instance of a class invokes all the superclasses’
constructors along the inheritance chain.
o This is known as constructor chaining.
35. Full Example
Methods of a subclass cannot directly access private members of their
superclass.
With inheritance, the common instance variables and methods of all the
classes in the hierarchy are declared in a superclass.
Use the protected access modifier when a superclass should
provide a method only to its subclasses and other classes in
the same package, but not to other clients.
36. Full Example
A subclass is more specific than its superclass and represents a smaller
group of objects.
A superclass's protected members have an intermediate level
of protection between public and private access. They can be
accessed by members of the superclass, by members of its
subclasses and by members of other classes in the same
package.
A compilation error occurs if a subclass constructor calls one
of its superclass constructors with arguments that do not match
the superclass constructor declarations.
37. Full Example
In Java, the class hierarchy begins with class Object (in package
java.lang), which every class in Java directly or indirectly extends.
Invoking a superclass constructor’s name in a subclass causes a syntax
error.
Java requires that the statement that uses the keyword super appear first
in the constructor.
If a class is designed to be extended, it is better to provide a no-arg
constructor to avoid programming errors.
38. Practices
Practice 1
Using charts, What is
Inheritance ?
Practice 2
Compare between the
Types of Inheritance
and which of them
supported in java.
Practice 3
By UML class, explain
the concepts of
Superclasses and
Subclasses.
Practice 4
Give 3 examples to
explain Direct & Indirect
Superclasses.
Practice 5
Diffrenciate between
"is-a" and the "has-
a" relationship.
Practice 6
Explain the
Constructor Chaining
using code.
39. Practices
Practice 7
True or false?
You can override a
private method
defined in a
superclass.
You can override a
static method
defined in a
superclass.
A subclass is a
subset of a
superclass.
Practice 8
Write simple code:
What keyword do
you use to define a
subclass?
How do you
explicitly invoke a
superclass’s
constructor from a
subclass?
How do you invoke
an overridden
superclass method
from a subclass?
Practice 9 (In groups)
Define The
GeometricObject,
Circle and Rectangle,
based on the
GeometricObject is the
superclass for Circle
Rectangle .