CS 21b Intro to Computing II. Object-Oriented Programming: Classes in Java.
Intro to java programming
-
Upload
leah-stephens -
Category
Documents
-
view
108 -
download
4
Transcript of Intro to java programming
![Page 1: Intro to java programming](https://reader036.fdocuments.us/reader036/viewer/2022062319/557a9319d8b42ac2638b541d/html5/thumbnails/1.jpg)
Intro to Java Programming
![Page 2: Intro to java programming](https://reader036.fdocuments.us/reader036/viewer/2022062319/557a9319d8b42ac2638b541d/html5/thumbnails/2.jpg)
Adgenda• Class Introductions• Brief History of Java• Installations
• Java JDK• Eclipse IDE
• High Level Overview of Java Language• Object Orientation Introduction
![Page 3: Intro to java programming](https://reader036.fdocuments.us/reader036/viewer/2022062319/557a9319d8b42ac2638b541d/html5/thumbnails/3.jpg)
Class Introductions• Name• Grade• Programming Experience
• Any languages other than java?• Favorite musical artist• What you expect to get from the class.
![Page 4: Intro to java programming](https://reader036.fdocuments.us/reader036/viewer/2022062319/557a9319d8b42ac2638b541d/html5/thumbnails/4.jpg)
BRIEF HISTORY OF JAVA
![Page 5: Intro to java programming](https://reader036.fdocuments.us/reader036/viewer/2022062319/557a9319d8b42ac2638b541d/html5/thumbnails/5.jpg)
Brief History of Java• Developed at Sun Microsystems by James
Gosling• Initial version was, called Oak, was based on C++
• Released in 1995 • Initial vision was to automate consumer devices
(TVs, cable boxes,VCRs etc.)• Released with the HotJava browser• Designed with a write once run anywhere
concept (Hardware independent)
![Page 6: Intro to java programming](https://reader036.fdocuments.us/reader036/viewer/2022062319/557a9319d8b42ac2638b541d/html5/thumbnails/6.jpg)
Brief History of Java
![Page 7: Intro to java programming](https://reader036.fdocuments.us/reader036/viewer/2022062319/557a9319d8b42ac2638b541d/html5/thumbnails/7.jpg)
INSTALLATIONS
![Page 8: Intro to java programming](https://reader036.fdocuments.us/reader036/viewer/2022062319/557a9319d8b42ac2638b541d/html5/thumbnails/8.jpg)
Installations• Copy the JavaClass directory from the USB
drive to your C drive• Run the java installer (either 32 or 64 bit
depending on your OS)• Extract the eclipse distribution archive into the
JavaClass directory on your C drive• Copy JarClassFinder to the eclipse dropins
directory• Install ObjectAid from the update site
(http://www.objectaid.net/update)
![Page 9: Intro to java programming](https://reader036.fdocuments.us/reader036/viewer/2022062319/557a9319d8b42ac2638b541d/html5/thumbnails/9.jpg)
Installations• Expand the JAutoDoc plugin into the eclipse
directory
![Page 10: Intro to java programming](https://reader036.fdocuments.us/reader036/viewer/2022062319/557a9319d8b42ac2638b541d/html5/thumbnails/10.jpg)
JAVA OVERVIEW
![Page 11: Intro to java programming](https://reader036.fdocuments.us/reader036/viewer/2022062319/557a9319d8b42ac2638b541d/html5/thumbnails/11.jpg)
Java Overview• Object oriented• Two types of java programs
• Standalone• Normal program run on a computer
• Can have a GUI or be headless
• Applet• Run inside a web browser
![Page 12: Intro to java programming](https://reader036.fdocuments.us/reader036/viewer/2022062319/557a9319d8b42ac2638b541d/html5/thumbnails/12.jpg)
Java Overview• Anatomy of a java class file
![Page 13: Intro to java programming](https://reader036.fdocuments.us/reader036/viewer/2022062319/557a9319d8b42ac2638b541d/html5/thumbnails/13.jpg)
OBJECT ORIENTATION
![Page 14: Intro to java programming](https://reader036.fdocuments.us/reader036/viewer/2022062319/557a9319d8b42ac2638b541d/html5/thumbnails/14.jpg)
Object Orientation• What is OO?
• An OO solution categorized into 3 phases• Analysis
• The analysis of a problem that focuses on the problem domain and the discovery of the domain entities and their interactions and relevant state information.
• Design• The process of taking the analysis output and refining and
extending it into a collection of cooperating classes that can be implemented to form a solution to a set of user requirements.
• Programming• An approach that facilitates creation of modular, reusable
components through the use of object oriented concepts.
![Page 15: Intro to java programming](https://reader036.fdocuments.us/reader036/viewer/2022062319/557a9319d8b42ac2638b541d/html5/thumbnails/15.jpg)
Object Orientation• OO Concepts
• Abstraction• The identification of the essential characteristics of an
item
• Encapsulation• The grouping of related concepts into one item, such as a
class or component
• Information hiding• The restriction of external access to attributes
• Aggregation• Represents “is part of” or “contains” relationships
between two classes or components
![Page 16: Intro to java programming](https://reader036.fdocuments.us/reader036/viewer/2022062319/557a9319d8b42ac2638b541d/html5/thumbnails/16.jpg)
Object Orientation• OO Concepts (Continued)
• Class• A template from which objects are
• Interface• The definition of a collection of one or more operation
signatures that defines a cohesive set of behaviors
• Collaboration• Classes work together (collaborate) to fulfill their
responsibilities
• Message• A message is either a request for information or a request
to perform an
![Page 17: Intro to java programming](https://reader036.fdocuments.us/reader036/viewer/2022062319/557a9319d8b42ac2638b541d/html5/thumbnails/17.jpg)
Object Orientation• OO Concepts (Continued)
• Operation• Something a class does (similar to a function in structured
programming)
• Inheritance (Single and Multiple)• Represents “is a”, “is like”, and “is kind of” relationships.
When class “B” inherits from class “A” it automatically has all of the attributes and operations that “A” implements
• Polymorphism• Different objects can respond to the same message in
different ways, enable objects to interact with one another without knowing their exact type
![Page 18: Intro to java programming](https://reader036.fdocuments.us/reader036/viewer/2022062319/557a9319d8b42ac2638b541d/html5/thumbnails/18.jpg)
Object Orientation• OO Concepts (Continued)
• Subclass• If class “B” inherits from class “A,” we say that “B” is a
subclass of “A”
• Superclass• If class “B” inherits from class “A,” we say that “A” is a
superclass of “B”
• Operation• Something a class does (similar to a function in structured
programming)
![Page 19: Intro to java programming](https://reader036.fdocuments.us/reader036/viewer/2022062319/557a9319d8b42ac2638b541d/html5/thumbnails/19.jpg)
Object Orientation• OO Concepts (Continued)
• Override• Sometimes you need to override (redefine) attributes
and/or methods in subclasses