10 - OOP - Method overloading and overriding
Heeeun Lim
Goals
- Understand method overloading and overriding
- Tell difference between overloading and overriding
- Implement overloading and overriding
Slides
Exercises
Exercise 1
- Create a class Human with properties: name and age
- Create a class Student which inherits Human and has additional property: schoolName
Exercise 2
- Implement constructors for Human and Student, which initialize all member variables
Exercise 3
- Implement printInfo method in Human and Student class
- printInfo should prints all member variables values
Exercise 4
- Implement printInfo method getting one argument "x" in Student class
- void printInfo(int x)
- printInfo(x) calls printInfo() "x" times
Exercise 5
- Implement two constructors in Student class
- Student(String name, int age)
- Student(String name, int age, String occupation)
Exercise 6
- Implement toString method in Human and Student class
- toString returns string printing all member variable values