Presentation is loading. Please wait.

Presentation is loading. Please wait.

CSE 341, S. Tanimoto Java brief review - 1 Java Brief Review Java’s strengths Object-oriented terminology Inheritance Interfaces An example with inheritance.

Similar presentations


Presentation on theme: "CSE 341, S. Tanimoto Java brief review - 1 Java Brief Review Java’s strengths Object-oriented terminology Inheritance Interfaces An example with inheritance."— Presentation transcript:

1 CSE 341, S. Tanimoto Java brief review - 1 Java Brief Review Java’s strengths Object-oriented terminology Inheritance Interfaces An example with inheritance and interfaces: class VisibleDataStructure

2 CSE 341, S. Tanimoto Java brief review - 2 Java’s Strengths Supports the objected-oriented paradigm Permits client-side execution of programs (Applets) on web pages. Provides portability of applications, including a standard graphics platform Supports networking including communication, parallelism, security. Provides a large standard library. Syntax close to that of C++.

3 CSE 341, S. Tanimoto Java brief review - 3 Object-Oriented Programming Terms object: encapsulation of data and code. class: a formal category of objects. instance: an object, in the context of a particular class. message: a request to an object or class for data or service. sender: the object or class from which the message comes. receiver: the object or class to which the message is sent. method: a function within a class that responds to a message.

4 CSE 341, S. Tanimoto Java brief review - 4 Inheritance One class can serve as a base class for defining a new, more restricted class called a subclass. Any instance of a (derived) class inherits the data members and method members of its parent class. A subclass typically provides additional member variables and methods. A subclass may override a member inherited from its parent by redefining it. An abstract class doesn’t provide full implementations of all of its methods and is typically used as a means to provide a uniform protocol to two or more separate subclasses. The visibility of names within and across inheritance hierarchies is controlled by the keywords public, private, protected. The default access control is “package” which itself defaults to accessibility within compilation units.

5 CSE 341, S. Tanimoto Java brief review - 5 Interfaces Since Java does not permit multiple inheritance with subclassing, (and therefore might have made it difficult for one class to integrate the functionality of several others) it compensates by providing formal interfaces. An interface consists of a name and a protocol (list of functions and their formal parameter types). A class may subclass at most one superclass but may implement any number of interfaces. A class that implements an interface must provide an implementation for each function appearing in the interface. Interfaces do not provide any code and are used to enforce (at compile time) calling conventions within software applications. Interfaces can be extended.

6 CSE 341, S. Tanimoto Java brief review - 6 An Overview of the VisibleDataStructure example VisibleDataStructure is an abstract class VisibleArray extends VisibleDataStructure VisibleVerticalArray extends VisibleArray VisibleHorizontalArray extends VisibleArray TestVisibleArray instantiates VisibleVerticalArray, and VisibleHorizontalArray


Download ppt "CSE 341, S. Tanimoto Java brief review - 1 Java Brief Review Java’s strengths Object-oriented terminology Inheritance Interfaces An example with inheritance."

Similar presentations


Ads by Google