Presentation is loading. Please wait.

Presentation is loading. Please wait.

Classes and Objects.

Similar presentations


Presentation on theme: "Classes and Objects."— Presentation transcript:

1 Classes and Objects

2 What is Java? Java is a programming language
Created by Sun Microsystems Often used for web programming Initially marketed as a web development system Java is not only for web programming General purpose programming language Very similar to C++ simplified! By Sara Almudauh

3 Java Program! class HiThere {
/** * This is the entry point for an application. astrArgs the command line arguments. */ public static void main(String[] astrArgs) { // Starting of the main method System.out.println("Hello World!"); } // main() } // end class HiThere By Sara Almudauh

4 Reserved words & Identifiers
class HiThere { public static void main(String[] astrArgs) { System.out.println("Hello World!"); } // main() } // end class HiThere Reserved words or keywords are part of the language class used to define a class public access keyword - public, private, protected and ‘default’ static type related to belonging void special return type Java is case sensitive By Sara Almudauh

5 Data Type The data type defines what kinds of values a space memory is allowed to store. All values stored in the same space memory should be of the same data type. All constants and variables used in a Java program must be defined prior to their use in the program.

6 Primitive Data Types Type Size (bits) Range Description boolean
true, false Stores a value that is either true or false. char 16 0 to 65535 Stores a single 16-bit Unicode character. byte 8 -128 to +127 Stores an integer. short to int 32 bits -2,147,483,648 to +2,147,483,647 long 64 bits -9,223,372,036,854,775,808 to +9,223,372,036,854,775,807 float accurate to 8 significant digits Stores a single-precision floating point number. double accurate to 16 significant digits Stores a double-precision

7 Variable/Constant Declaration
When the declaration is made, memory space is allocated to store the values of the declared variable or constant. The declaration of a variable means allocating a space memory which state (value) may change. The declaration of a constant means allocating a space memory which state (value) cannot change.

8 Variable Declaration A variable may be declared: With initial value.
Without initial value Variable declaration with initial value; dataType variableIdentifier = literal | expression; double avg = 0.0; int i = 1; int x =5, y = 7, z = (x+y)*3; Variable declaration without initial value; dataType variableIdentifier; double avg; int i;

9 More declaration examples
String declaration with initial value: String word="Apple"; without initial value: String word; char declaration char symbol ='*'; char symbol; Boolean declaration: with initial value: boolean flag=false; boolean valid=true; without initial value: boolean flag;

10 Arithmetic 9 5 14 3 1 iNum += 2; int iNum = 7; iNum -= 2; iNum *= 2;
Arithmetic Unary Operators += addition -= subtract *= multiply /= divide %= remainder iNum += 2; iNum -= 2; iNum *= 2; iNum /= 2; iNum %= 2; int iNum = 7; 9 5 14 3 1 By Sara Almudauh

11 Operators int iNum = 7; Equality and Relational Operators
== equal to if (iNum == 1) { != not equal to if (iNum != 1) { > greater than if (iNum > 1) { >= greater than or equal to if (iNum >= 1){ < less than if (iNum < 1) { <= less than or equal if (iNum == 1) { int iNum = 7; By Sara Almudauh

12 Decision Making Conditions result in boolean values Condition can be
A boolean Expressions that result in a boolean Combination of Rational Operators and Method that return boolean By Sara Almudauh

13 Decision Making Rational Operators == is equal to != is not equal to
> is bigger than >= is bigger or equal to < is smaller than <= is smaller or equal to || logical OR && logical AND counterA == counterB counterA != counterB counterA > counterB counterA >= counterB counterA < counterB counterA <= counterB (counterA > counterB) || (counterA < counterB) (counterA > counterB) && (counterA < counterB) By Sara Almudauh

14 Decision Making switch Statement
A way to simulate multiple if statements int iCounter = 0; // initialisation int iValue; ... if (iCounter == 0) { iValue = -1; } else if (iCounter == 1) { iValue = -2; } else if (iCounter == 2) { iValue = -3; } else { iValue = -4; } int iCounter = 0; // initialisation int iValue; ... switch (iCounter) { case 0: iValue = -1; break; case 1: iValue = -2; case 2: iValue = -3; default: iValue = -4; } // end switch By Sara Almudauh

15 Two-Way Selection Example 4-13 if (hours > 40.0)
wages = rate * hours; else wages = hours * rate;

16 Switch Structures Expression is also known as selector.
switch (expression) { case value1: statements1 break; case value2: statements2 ... case value n: statements n default: statements } Expression is also known as selector. Expression can be an identifier. Value can only be integral.

17 Control Structures Loops while do for Loop Control break continue
By Sara Almudauh

18 Initialisation - Condition - Increment
Control Structures Initialisation - Condition - Increment int iIndex = 0; // initialise do { System.out.println(iIndex); iIndex += 2; } while (iIndex < 4); ... int iIndex = 0; // initialise while (iIndex < 4) { System.out.println(iIndex); iIndex += 2; } // end while ... for (int iIndex = 0; iIndex < 4; iIndex += 2) { System.out.println(iIndex); } // end for ... By Sara Almudauh

19 Arrays Group of data items All items of the same type, e.g. int
Items accessed by integer indexes Starting index with zero Last index is one less than the length Of pre-determinate size The length of an array is the number of items it contains The length is fixed at creation time By Sara Almudauh

20 Arrays By Sara Almudauh

21 Declaring Array Variables
Arrays are variables Arrays must be declared <type>[] <identifier>; or <type> <identifier>[]; Examples: String[] astrCityNames; or String astrCityNames[]; int[] aiAmounts; or int aiAmounts[]; double myList[]; By Sara Almudauh

22 Creating Arrays arrayRefVar = new datatype[arraySize]; Example:
myList = new double[10]; myList[0] references the first element in the array. myList[9] references the last element in the array. By Sara Almudauh

23 Declaring and Creating in One Step
datatype[] arrayRefVar = new datatype[arraySize]; double[] myList = new double[10]; datatype arrayRefVar[] = new datatype[arraySize]; double myList[] = new double[10]; By Sara Almudauh

24 Example double[] myList = {1.9, 2.9, 3.4, 3.5};
This is equivalent to the following statements: double[] myList = new double[4]; myList[0] = 1.9; myList[1] = 2.9; myList[2] = 3.4; myList[3] = 3.5; By Sara Almudauh

25 Initializing arrays with input values
Scanner input = new Scanner(System.in); System.out.print("Enter " + myList.length + " values: "); for (int i = 0; i < myList.length; i++) myList[i] = input.nextDouble(); By Sara Almudauh

26 Object Software objects are modeled after real-world objects in that they, too, have state and behavior. A software object maintains its state in variables and implements its behavior with methods. An object combines data and operations on the data into a single unit.

27 Object An approach to the solution of problems in which all computations are performed in the context of objects. ◦The objects are instances of classes, which: are data abstractions contain procedural abstractions that operate on the objects ◦A running program can be seen as a collection of objects collaborating to perform a given task

28 Dr. S. GANNOUNI & Dr. A. TOUIR
Object vs. Class A class could be considered as a set of objects having the same characteristics and behavior. An object is an instance of a class. Introduction to OOP Dr. S. GANNOUNI & Dr. A. TOUIR

29 Classes User-defined data types Contain Variables
Often called “properties”, “members” or “attribute” of the class Contain blocks of program code “methods” Instance variables and methods This is the default Each instance of the class has their own copy Class variables and methods Declared using the reserved word “static” Only one copy for all instances of the class

30 Object vs. Class A class could be considered as a set of objects having the same characteristics and behavior. An object is an instance of a class.

31 Declaring a Class with Java
Methods (Services) Attributes ClassName att1: dataType1 atti: dataTypei + m1(…): dataType1 + ... + mj(…): dataTypej public class ClassName { // Attributes // Methods (services) } Introduction to OOP Dr. S. GANNOUNI & Dr. A. TOUIR

32 Declaring Attributes With Java
<modifiers> <data type> <attribute name> ; Modifiers Data Type Name public String studentName ; Introduction to OOP Dr. S. GANNOUNI & Dr. A. TOUIR

33 Example of a Class Declaration with Java
public class Course { // Attributes public String studentName; public String courseCode ; // No method Members } Introduction to OOP Dr. S. GANNOUNI & Dr. A. TOUIR

34 Objects An instance of a class
Created when the class is instantiated with the new reserved word Generally classes must be instantiated before they can be used For example class Stuff is instantiated as follows: Stuff myStuff = new Stuff(); The exception Static variables and methods may be used without instantiating a class Naming convention class names should start with an uppercase letter

35 Dr. S. GANNOUNI & Dr. A. TOUIR
Object Creation crs A. The instance variable is allocated in memory. Object: Course studentName courseCode B. The object is created A B Course crs; crs = ; C C. The reference of the object created in B is assigned to the variable. new Course ( ) crs Object: Course studentName courseCode If the variable refers to an object, then the assignment and the corresponding effect to the memory allocation are different. Notice the content of the variable is not the value itself, as is the case with primitive data, but the address of, or reference to, the memory location where the object data is stored. We use arrows to indicate this memory reference. Code State of Memory Introduction to OOP Dr. S. GANNOUNI & Dr. A. TOUIR

36 Instance VS. Primitive Variables
Primitive variables hold values of primitive data types. Instance variables hold references of objects: the location (memory address) of objects in memory. Introduction to OOP Dr. S. GANNOUNI & Dr. A. TOUIR

37 Assigning Objects’ References to the same Instance Variable
crs A. The variable is allocated in memory. B. The reference to the new object is assigned to crs. Course C. The reference to another object overwrites the reference in crs. Course A Course crs; crs = new Course ( ); B C If the variable refers to an object, then the assignment and the corresponding effect to the memory allocation are different. Notice the content of the variable is not the value itself, as is the case with primitive data, but the address of, or reference to, the memory location where the object data is stored. We use arrows to indicate this memory reference. Code State of Memory Introduction to OOP Dr. S. GANNOUNI & Dr. A. TOUIR

38 Assigning an Object Reference From One Variable to Another
A. Variables are allocated in memory. crs1 crs2 B. The reference to the new object is assigned to crs1 . Course C. The reference in crs1 is assigned to crs2. A B Course crs1, crs2, crs1 = new Course( ); crs2 = crs1; C This sample code shows the effect of two reference variables pointing to the same object, which is perfectly legal. This slide highlights the critical fact that the name (variable) and object are two distinct and separate entities. It is no problem to have multiple variables referring to a single object, much as a single person can be referred by many different names. Code State of Memory Introduction to OOP Dr. S. GANNOUNI & Dr. A. TOUIR

39 Assigning an Object Reference From One Variable to Another
A. Variables are allocated in memory. crs1 crs2 Course B. Variables are assigned references of objects. A C. The reference in crs2 is assigned to crs1. Course crs1, crs2, crs1 = crs2; B crs1 = new Course( ); crs2 = new Course( ); Course crs1 crs2 C Introduction to OOP Dr. S. GANNOUNI & Dr. A. TOUIR

40 Accessing Instance Attributes
In order to access attributes of a given object: use the dot (.) operator with the object reference (instance variable) to have access to attributes’ values of a specific object. instanceVariableName.attributeName course1.StudentName= “Sara AlKebir“; course2.StudentName= “Maha AlSaad“; course2 course1 Object: Course studentName Majed AlKebir courseCode Object: Course studentName Fahd AlAmri courseCode Introduction to OOP Dr. S. GANNOUNI & Dr. A. TOUIR

41 Dr. S. GANNOUNI & Dr. A. TOUIR
class Course { // Instance attributes public String studentName; public String courseCode ; } public class CourseRegistration { public static void main(String[] args) { Course course1, course2; //Create and assign values to course1 course1 = new Course( ); course1.courseCode= new String(“CSC112“); course1.studentName= new String(“Sara AlKebir“); //Create and assign values to course2 course2 = new Course( ); course2.courseCode= new String(“CSC107“); course2.studentName= new String(“Maha AlSaad“); System.out.println(course1.studentName + " has the course “+ course1.courseCode); System.out.println(course2.studentName + " has the course “+ course2.courseCode); } Introduction to OOP Dr. S. GANNOUNI & Dr. A. TOUIR

42 Dr. S. GANNOUNI & Dr. A. TOUIR
Practical hint Class Course will not execute by itself It does not have method main CourseRegistration uses the class Course. CourseRegistration, which has method main, creates instances of the class Course and uses them. Introduction to OOP Dr. S. GANNOUNI & Dr. A. TOUIR

43 Class and Objects

44 Constructors Constructors are special methods that are executed automatically Executed once when the class is instantiated Constructors have the same name as the class They have no return value, but must not be declared void class Stuff { Stuff() System.out.println(“This is the constructor”); }

45 Use of constructors Constructors are run once when a class is instantiated useful for initialising the object - any code that needs to be run to set things up in memory useful for passing data into the object from the calling program in graphical programs the user interface is usually defined in the constructor of a “window” object the fact that they are only run once is useful - this is a good place for any code that must be run only once

46 Constructors Constructors are a special kind of methods that are invoked to construct objects. Circle() { } Circle(double newRadius) { radius = newRadius;

47 Default Constructor A class may be declared without constructors. In this case, a no-arg constructor with an empty body is implicitly declared in the class. This constructor, called a default constructor, is provided automatically only if no constructors are explicitly declared in the class.

48 static Public+ Private - Protected #
Modifiers static Public+ Private - Protected #

49 Dr. S. GANNOUNI & Dr. A. TOUIR
Static It used to define class attributes and methods. Class attributes (and methods): live in the class can also be manipulated without creating an instance of the class. are shared by all objects of the class. do not belong to objects’ states. <modifiers> <data type> <attribute name> ; Modifiers Data Type Name public static int studentNumber ; Introduction to OOP Dr. S. GANNOUNI & Dr. A. TOUIR

50 Class Attributes Access
Class attributes (and methods) can also be manipulated without creating an instance of the class. <class name>.<attribute name> Class Name Attribute Name Course.studentNumber = 0 ; Introduction to OOP Dr. S. GANNOUNI & Dr. A. TOUIR

51 Instance Data Most class members are associated with an instance of the class. public class Foo { public int x ; public static void main(String[] args) { Foo a = new Foo() ; Foo b = new Foo() ; a.x = 2 ; b.x = 15 ; /* a.x=2, b.x=15 */ } By Sara Almudauh

52 public static void main(String[] args) {
Static Data Members declared static are associated with the class as a whole. There is only one copy shared between all instances. public class Foo { public static int x ; public static void main(String[] args) { Foo a = new Foo(), b = new Foo() ; a.x = 2 ; b.x = 15 ; /* a.x=15, b.x=15 */ } By Sara Almudauh

53 public static void main(String[] args) { Student st1 = new Student();
public class Student { String name; int ID; String course; public static void main(String[] args) { Student st1 = new Student(); st1.name="sara Almudauh"; st1.ID=4200; st1.course="Programming"; System.out.println("Student name is : "+ st1.name); System.out.println("Student ID is : "+ st1.ID); System.out.println("Student course is : "+ st1.course); } By Sara Almudauh

54 Student name is : sara Almudauh Student ID is : 4200
Student course is : Programming Process completed. By Sara Almudauh

55 Dr. S. GANNOUNI & Dr. A. TOUIR
class Course { // attributes public String studentName; public String courseCode ; public static int studentNumber; } public class CourseRegistration { public static void main(String[] args) { Course course1, course2; //Create and assign values to course1 course1 = new Course( ); Course.studentNumber = 1; course1.courseCode= new String(“CT1513“); course1.studentName= new String(“Sara AlKebir“); //Create and assign values to course2 course2 = new Course( ); Course.studentNumber ++; course2.courseCode= new String(“CSC107“); course2.studentName= new String(“Maha AlSaad “); System.out.println(course1.studentName + " has the course “+ course1.courseCode + “ ” + course1.studentNumber); System.out.println(course2.studentName + " has the course “+ course2.courseCode + “ ” + course2.studentNumber); } Introduction to OOP Dr. S. GANNOUNI & Dr. A. TOUIR

56

57 public and private modifiers
Let’s consider a class X. Let’s consider Y a client class of X. Y is a class that uses X. Attributes (and methods) of X declared with the public modifier are accessible from instances of Y. The public modifier does not guarantee the information hiding. Attributes (and methods) of X declared with the private modifier are not accessible from instances of Y. The private modifier guarantee the information hiding.

58 Accessibility from Inside (the Instance itself)
object:X Accessible Inaccessible public private All members of an instance are accessible from the instance itself.

59 Accessibility from an Instance of another Class
object:X public private Accessible Inaccessible :Y(client) Accessibility from The Client class. Only public members Are visible from outside. All else is hidden from Outside.

60 UML Representation of a Class (UML Class Diagram)
UML uses three symbols to represent the visibility of the class’ members. + : mentions that the member is public. - : mentions that the member is private. # : introduced later. Methods (Services) Attributes ClassName att1: dataType1 atti: dataTypei + m1(…): dataType1 + ... + mj(…): dataTypej

61 Declaring Private Attributes
<modifiers> <data type> <attribute name> ; Modifiers Data Type Name private String studentName ;

62 Example of a Class with Private attributes
ClassName studentName: String courseCode: String public class Course { // Attributes private String studentName; private String courseCode ; // No method Members }

63 class Course { // Data Member private String studentName; private String courseCode ; } public class CourseRegistration { public static void main(String[] args) { Course course1, course2; //Create and assign values to course1 course1 = new Course( ); course1.courseCode= “Ct1513“; course1.studentName= “Sara AlKebir“; //Create and assign values to course2 course2 = new Course( ); course2.courseCode= “CSC107“; course2.studentName= “Maha AlSaad“; System.out.println(course1.studentName + " has the course “+ course1.courseCode); System.out.println(course2.studentName + " has the course “+ course2.courseCode); }

64 Accessibility Example
Service obj = new Service(); obj.memberOne = 10; obj.memberTwo = 20; obj.doOne(); obj.doTwo(); class Service { public int memberOne; private int memberTwo; public void doOne() { } private void doTwo() { } This is a simple example of public and private modifiers. See how the client can access the public data member and method. Client Service

65 Methods

66 Method Declaration Method declaration is composed of: Method header.
Method body <method header> { <method body> }

67 Method Declaration (cont.)
<modifiers> <return type> <method name> ( <parameters> ){ <method body> } Modifier Return Type Method Name Parameters public void setOwnerName ( String name ) { ownerName = name; } Method body

68 Example of Methods with No-Parameters and No-Return value
import java.util.Scanner; public class Course { // Attributes private String studentName; private String courseCode ; private static Scanner input = new Scanner(System.in); //Class att. // Methods public void enterDataFromKeyBoard() { System.out.print (“Enter the student name: ”); studentName = input.next(); System.out.print (“Enter the course code: ”); courseCode = input.next(); } public void displayData() { System.out.println (“The student name is: ” + studentName); System.out.println (“The the course code is: ”+ courseCode);

69 Method Invocation Invoking a method of a given object requires using:
the instance variable that refers to this object. the dot (.) operator as following: instanceVariable.methodName(arguments) public class CourseRegistration { public static void main(String[] args) { Course course1, course2; //Create and assign values to course1 course1 = new Course( ); course1.enterDataFromKeyBoard(); course1.display(); //Create and assign values to course2 course2 = new Course( ); course2.enterDataFromKeyBoard(); course2.display(); }

70 Method Invocation Execution Schema
class Client { public static void main(String[] arg) { X obj = new X(); // Block statement 1 obj.method(); // Block statement 2 } . . . class X { . . . public void method() { // Method body } The client Block statement 1 executes Passing Parameters if exist The method Invocation The method body starts Return result if any The method body finishes Block statement 2 starts The client

71 Example of a Method with Return value
public class Student { // Attributes public String studentName; public int midTerm1, midTerm2, lab, final ; // Methods public int computeTotalMarks() { int value = mid1 + mid2 + lab + final; return value; } public class TestStudent { public static void main (String [] args) { Student st = new Student(); int total; total = st.computeTotalMarks(); System.out.println(total); }

72 Arguments and Parameters
An argument is a value we pass to a method. A parameter is a placeholder in the called method to hold the value of the passed argument. class Account { . . . public void add(double amt) { balance = balance + amt; } Formal parameter class Sample { public static void main(String[] arg) { Account acct = new Account(); . . . acct.add(400); } Argument (Actual Parameter)

73 Getter, Setter and Constructor
Information Hiding

74 How Private Attributes could be Accessed
Private attributes are accessible from outside using accessor operations. Getters Setters

75 class Course { // Data Member private String studentName; private String courseCode ; } public class CourseRegistration { public static void main(String[] args) { Course course1, course2; //Create and assign values to course1 course1 = new Course( ); course1.courseCode= “CT1513“; course1.studentName= “Sara AlKebir“; //Create and assign values to course2 course2 = new Course( ); course2.courseCode= “CT1413“; course2.studentName= “Maha AlSaad“; System.out.println(course1.studentName + " has the course “+ course1.courseCode); System.out.println(course2.studentName + " has the course “+ course2.courseCode); }

76 public class Course { // Attributes private String studentName; private String courseCode ; ... public String getStudentName() { return studentName; } public String getCourseCode() { return courseCode; public void setStudentName(String val) { studentName = val; public void setCourseCode(String val) { courseCode = val;

77 public class CourseRegistration {
public static void main(String[] args) { Course course1, course2; //Create and assign values to course1 course1 = new Course( ); course1.setCourseCode(“CT1513“); course1.setStudentName(“Sara AlKebir“); //Create and assign values to course2 course2 = new Course( ); course2.setCourseCode(“CT1413“); course2.setStudentName(“Maha AlSaad“); System.out.println(course1.getStudentName() + " has the course “ + course1.getCourseCode()); System.out.println(course2.getStudentName() + " has the course “ + course2.getCourseCode()); }

78 Class Constructors A class is a blueprint or prototype from which objects of the same type are created. Constructors define the initial states of objects when they are created. ClassName x = new ClassName(); A class contains at least one constructor. A class may contain more than one constructor.

79 The Default Class Constructor
If no constructors are defined in the class, the default constructor is added by the compiler at compile time. The default constructor does not accept parameters and creates objects with empty states. ClassName x = new ClassName();

80 Class Constructors Declaration
public <constructor name> ( <parameters> ){ <constructor body> } The constructor name: a constructor has the name of the class . The parameters represent values that will be passed to the constructor for initialize the object state. Constructor declarations look like method declarations—except that they use the name of the class and have no return type.

81 Example of a Constructor with No-Parameter
public class rectangular{ private int width; private int length; public rectangular() { width= 0; length=0; } . . . A. The instance variable is allocated in memory. x Object: Kasree width length B. The object is created with initial state A B rectangular x; x = ; C new rectangular( ) State of Memory Code

82 Class with Multiple Constructors
public class rectangular{ private int width; private int length; public rectangular() { width= 0; length=0; } public rectangular(int a, int b) { width = a; length=b; . . . A. The constructor declared with no-parameter is used to create the object x Object: Kasree bast maquam 1 B. The constructor declared with parameters is used to create the object y Object: Kasree bast maquam 3 4 A Kasree x , y; x = new Kasree() y = new Kasree(4, 3); B State of Memory Code

83 Introduction to Inheritance
Technique for deriving a new class from an existing class. Existing class called superclass, base class, or parent class. New class is called subclass, derived class, or child class.

84 Introduction to Inheritance
Why inheritance? Employee class: name, salary, hireDay; getName, raiseSalary(), getHireDay(). Manager is-a Employee, has all above, and Has a bonus getsalary() computed differently Instead of defining Manager class from scratch, one can derive it from the Employee class. Work saved.

85 Introduction to Inheritance
Account method A checking method B1 saving method B2 superclass subclass

86 Examples

87 Fig. 9.2 | Inheritance hierarchy for university CommunityMembers

88 Fig. 9.3 | Inheritance hierarchy for Shapes.

89 Deriving a Subclass General scheme for deriving a subclass:
class subClassName extends superClassName { constructors refined methods additional methods additional fields } Indicate the differences between subclass and superclass

90 Deriving a class class Employee {
public Employee(String n, double s, int year, int month, int day) {…} public String getName(){…} public double getSalary() {…} public Data getHireDay(){…} public void raiseSalary(double byPercent) {…} private String name; private double Salary; private Date hireDay; }

91 Deriving a class Extending Employee class to get Manager class
class Manager extends Employee { public Manager(…) {…} // constructor public void getSalary(…) {…} // refined method // additional methods public void setBonus(double b){…} // additional field private double bonus; }

92 Overriding Methods Salary computation for managers are different from employees. So, we need to modify the getSalary, or provide a new method that overrides getSalary public double getSalary( ) { double baseSalary = super.getSalary(); return basesalary + bonus; } Cannot replace the last line with salary += bonus; Because salary is private to Employee. Call method of superclass

93 Overriding Methods An overriding method must have the same signature (name and parameter list) as the original method. Otherwise, it is simply a new method: Original Method in Employee: public double getSalary( ){…} public void raiseSalary(double byPercent){…} New rather than overriding methods in Manager: public void raiseSalary(int byPercent){…} public void raiseWage(double byPercent){…}


Download ppt "Classes and Objects."

Similar presentations


Ads by Google