Presentation is loading. Please wait.

Presentation is loading. Please wait.

CS240: Advanced Programming Concepts

Similar presentations


Presentation on theme: "CS240: Advanced Programming Concepts"— Presentation transcript:

1 CS240: Advanced Programming Concepts
Week 5 Thursday

2 Inheritance Continued…
Scope Private “Mine” Cannot be seen/accessed by any other class – including subclasses Use public/protected methods to access… Protected Visible within the package… Visible to subclasses outside of the package – but only for instances of the subclass type Public “Everyone’s”

3 Interface Variables Interfaces CAN have variables but they must/will be public, static, and final Note: this is implicit – it happens without you invoking the keywords…

4 Abstract Methods In interfaces… In Classes
This is basically our default practice… In Classes If a method is declared but not defined (i.e. no {}) then it is treated as abstract. If one or more methods in a class are abstract the class itself must be declared abstract public abstract class <ClassName> …

5 Static / Default Methods in Interfaces
Static methods Not originally included in the language – considered a violation of the interface paradigm Now OK Enables “Interface Evolution” – discuss… Default methods Provided as a means of “offering” a default method to implementing classes Also Enables graceful “Interface Evolution” Makes it possible to add methods to an interface without breaking compilation of older code Prevents runtime errors when running previously compiled older code

6 Method Conflicts When a class implements two interfaces that have a method naming conflict the implementer must de-conflict the methods (i.e. by implementing the method and calling one of the interfaces’ version) If a naming conflict arises when a class implements an interface and extends a superclass the superclass is dominant…

7 Static Factory Methods…
Factory methods “manufacture” objects of a particular class Can be static methods – no need for an instance to call them ( i.e. getInstance() ) Discuss Sometimes you don’t want your constructor to be public… Utility Class Singleton

8 Project 1: Super Asteroids
Deliverables: Design Document: October 11th (6% of your total grade) Working Program: October 27th (24% of your total grade) Code Evaluation: October 27th (6% of your total grade)


Download ppt "CS240: Advanced Programming Concepts"

Similar presentations


Ads by Google