CST338 - Week 12
- YZ

- Mar 31, 2020
- 2 min read
Give an example of polymorphism and what would be inherited between classes.
Polymorphism allows the use of one method with many meanings. For example,
you can have a class called MiddleSchoolStudents. Then you can define 3 classes named SixthGraders, SeventhGraders, and EighthGraders, which all have the phrase "extends MiddleSchoolStudents". Then you can invoke a method called getSchedule() which will print out the student schedule depending on what grade they are in. When the method is invoked with a particular student, the program identifies which grade the student is in, and uses the method definition from the right class.
What is the difference between Abstract classes and Interfaces?
Abstract classes are classes in which you do not complete one or more method definition(s) which can be defined in a derived class. Abstract classes can contain complete method definitions and instance variables. Also, derived classes can only be derived from one abstract class.
Interfaces are a type with a list of methods that must be present in a class that implements the interface. Interfaces do not contain instance variables and cannot include a complete method definition. Additionally, classes can implement more than one interface.
Java Optical Barcode Readers and Writers

This week's Java program focused on reading and writing barcodes. I never realized how barcodes worked and were translated until this assignment! The fact that each pixel has a value and can be added to generate an ASCII character and then translate to text is fascinating! The work was difficult - definitely a big jump from last week. Luckily, I have amazing teammates and they helped me review my code, debug, and fix it up. After I finished, I felt very accomplished when we tested it out and it actually worked! It was very interesting to work on a program that you can clearly see how it is used in the real world.



Comments