 2003 Joel C. Adams. All Rights Reserved. Calvin CollegeDept of Computer Science(1/10) An Overview of Objects and the Java API Joel Adams and Jeremy Frens.

Slides:



Advertisements
Similar presentations
Designing a Program & the Java Programming Language
Advertisements

In Review JAVA C++ GUIs - Windows Webopedia.com.
Lab Information Security Using Java (Review) Lab#0 Omaima Al-Matrafi.
Lab#1 (14/3/1431h) Introduction To java programming cs425
The Life and Times of Andrew Bardee and Chris Cornelius Programming Languages Fall 2011.
Slides prepared by Rose Williams, Binghamton University Chapter 1 Getting Started 1.1 Introduction to Java.
1-1 CMPU125 Topics in Computer Science Lecture 1 Jenny Walter Fall 2008.
Object Oriented System Development with VB .NET
Principles of Object-oriented Programming Programming Language Paradigms August 26, 2002.
Java Programming, 3e Concepts and Techniques Chapter 1 An Introduction to Java and Program Design.
1 An Introduction to Visual Basic Objectives Explain the history of programming languages Define the terminology used in object-oriented programming.
Introduction to Java.
1. 2 Chapter 1 Introduction to Computers, Programs, and Java.
Lecture 1: Overview of Java. What is java? Developed by Sun Microsystems (James Gosling) A general-purpose object-oriented language Based on C/C++ Designed.
CSE 1301 J Lecture 2 Intro to Java Programming Richard Gesick.
L EC. 01: J AVA FUNDAMENTALS Fall Java Programming.
CMSC 202 Computer Science II for Majors Fall 2009 Introduction.
Chapter 1 - Introduction. Ch 1Goals To understand the activity of programming To learn about the architecture of computers To learn about machine code.
Java Programming, 2E Introductory Concepts and Techniques Chapter 1 An Introduction to Java and Program Design.
+ Java vs. Javascript Jessi Style. + Java Compiled Can stand on its own Written once, run anywhere Two-stage debugging Java is an Object Oriented Programming.
Java Workshop for Teachers May 6, 2005 A Brief Look at the Java Programming Language.
220 FINAL TEST REVIEW SESSION Omar Abdelwahab. INHERITANCE AND POLYMORPHISM Suppose you have a class FunClass with public methods show, tell, and smile.
CMSC 202 Computer Science II for Majors Object-Oriented Programming.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Programming Languages Machine.
111 © 2002, Cisco Systems, Inc. All rights reserved.
CSE 1340 Class 3. Class 03 objectives State the difference between Machine Language vs. High Level Languages Discuss some characteristics of the Java.
Introduction to Computers and Java Chapter 1.3. A Sip of Java: Outline History of the Java Language Applets A First Java Program Compiling a Java Program.
Session One Introduction. Personal Introduction Role of programmers Robot Examination HUD & HID Uploading Code.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and Server Side Programming Very rich GUI libraries Portability (machine independence) A.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to.
Module Overview n Module Title: OO Programming n Module Code: MIT3446 n Module Value: 3.0 n Duration: 15 weeks n Class-Contact Hours: Lecture15 hrs n Lab/Tutor30hrs.
Jaeki Song ISQS6337 JAVA Lecture 03 Introduction to Java -The First Java Application-
© 2012 Pearson Education, Inc. All rights reserved. 1-1 Why Java? Needed program portability – Program written in a language that would run on various.
Introduction to C++ Programming Language
Java Programming, Second Edition Chapter One Creating Your First Java Program.
An Introduction to Software Development Java Methods A & AB Object-Oriented Programming and Data Structures Maria Litvin ● Gary Litvin Copyright © 2006.
Java Programming, 2E Introductory Concepts and Techniques Chapter 1 An Introduction to Java and Program Design.
CHAPTER 3 GC Java Fundamentals. 2 BASICS OF JAVA ENVIRONMENT  The environment  The language  Java applications programming Interface API  Various.
Chapter 1 Section 1.1 Introduction to Java Slides prepared by Rose Williams, Binghamton University Kenrick Mock, University of Alaska Anchorage.
Java for C++ Programmers Clint Jeffery University of Idaho
National Taiwan University Department of Computer Science and Information Engineering National Taiwan University Department of Computer Science and Information.
Chapter 2: A Brief History Object- Oriented Programming Presentation slides for Object-Oriented Programming by Yahya Garout KFUPM Information & Computer.
4-Nov-15 Air Force Institute of Technology Electrical and Computer Engineering Object-Oriented Programming Design Topic 1: The Java Environment Maj Joel.
 2003 Joel C. Adams. All Rights Reserved. Calvin CollegeDept of Computer Science(1/15) MVC and Swing Joel Adams and Jeremy Frens Calvin College.
CSE S. Tanimoto Java Introduction 1 Java A Programming Language for Web-based Computing with Graphics.
C++ Programming Basic Learning Prepared By The Smartpath Information systems
Computer Programming 2 Why do we study Java….. Java is Simple It has none of the following: operator overloading, header files, pre- processor, pointer.
J ava P rogramming: From Problem Analysis to Program Design, From Problem Analysis to Program Design, Second Edition Second Edition D.S. Malik D.S. Malik.
1 The JAVA Language Object Oriented Technology Mithani Binjan M.
Application Architecture Using Java Hong Li. Introduction Developed by a team led by James Gosling at Sun Microsystem. Originally called Oak, designed.
Liang, Introduction to Java Programming, Seventh Edition, (c) 2009 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to.
© 2012 Pearson Education, Inc. All rights reserved types of Java programs Application – Stand-alone program (run without a web browser) – Relaxed.
Today… “Hello World” ritual. Brief History of Java & How Java Works. Introduction to Java class structure. But first, next slide shows Java is No. 1 programming.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. CSC 110 – INTRO TO COMPUTING - PROGRAMMING Overview of Programming.
Execution ways of program References: www. en.wikipedia.org/wiki/Integrated_development_environment  You can execute or run a simple java program with.
Computer Programming Week 1: The Basics of CP 1 st semester 2012 School of Information Technology Website:
Java Programming, 3e Concepts and Techniques Chapter 1 Section 56 – An Introduction to Java.
 It is a pure oops language and a high level language.  It was developed at sun microsystems by James Gosling.
CMSC 202 Computer Science II for Majors Fall 2010 Introduction Version 9/101.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Fundamental of Java Programming (630002) Unit – 1 Introduction to Java.
Introduction CMSC 202 Fall Instructors Mr. Ryan Bergeron – Lecture Section 01 Tues/Thu 1:00 – 2:15 am, Sondheim 111 – Lecture Section 04 Tues/Thu.
GC101 Introduction to computer and program
Chapter 1 Introduction to Computers, Programs, and Java
Introduction Enosis Learning.
Introduction Enosis Learning.
(Computer fundamental Lab)
Outcome of the Lecture Upon completion of this lecture you will be able to understand Fundamentals and Characteristics of Java Language Basic Terminology.
Presentation transcript:

 2003 Joel C. Adams. All Rights Reserved. Calvin CollegeDept of Computer Science(1/10) An Overview of Objects and the Java API Joel Adams and Jeremy Frens Department of Computer Science Calvin College

 2003 Joel C. Adams. All Rights Reserved. Calvin CollegeDept of Computer Science(2/10) Where did Java come from? Object-oriented programming:  Late 1970s: Xerox PARC (GUIs, Ethernet, Laserprinters,...)  Smalltalk (Adele Goldberg)  Classes of objects  Objects communicate via messages  Everything allocated dynamically  Mid-1980s: Bell Labs  C++ (Bjarne Stroustrup): “C with Classes”, a hybrid language  Early 1990s: Sun Microsystems  Java (James Gosling): “Just another virtual architecture”  Syntax like C++, features like Smalltalk  Byte code compiler  Virtual machine (interpreter)  Garbage collector

 2003 Joel C. Adams. All Rights Reserved. Calvin CollegeDept of Computer Science(3/10) When people say “Java” they may mean: What is Java? MS’s.Net gives much of this, except platform-independence. Much of what we will cover also applies to VB.Net.  An object-oriented programming language  A developers kit (compiler, debugger, …)  A run-time environment small enough to be built-in to a web browser, cell-phone, cable-box, …  A platform-independent system that strives for “write once, run anywhere” portability anywhere on the Internet

 2003 Joel C. Adams. All Rights Reserved. Calvin CollegeDept of Computer Science(4/10) Classes and Objects What is a class? Think “typhoon-class submarine” or “galaxy-class starship”:  A mechanism for creating new types  A means of declaring a container to store both  variables to store an object’s attributes (internal state); and  messages to which an object will respond (behavior)  A factory for constructing related objects What is an object?  An object is an instance of a class.

 2003 Joel C. Adams. All Rights Reserved. Calvin CollegeDept of Computer Science(5/10) Suppose we needed to represent fractions (1/2, 3/4) exactly… A Simple Java Class To store a fraction’s internal state, we need variables to hold its numerator and denominator class Fraction {... } private int myNumerator; private int myDenominator; We then define a method for each message to which we want a Fraction to respond public int getNumerator() { return myNumerator; } public int getDenominator() { return myDenominator; } A fair amount of design time goes into deciding what methods a class should provide for its users

 2003 Joel C. Adams. All Rights Reserved. Calvin CollegeDept of Computer Science(6/10) class FractionTester { public static void main(String [] args) { } Creating and Using Objects Once we have an operational Fraction class… we can use it to create Fraction instances Fraction frac1 = new Fraction(); Fraction frac2 = new Fraction(3,4); if ( frac1.getDenominator() != 0) { // do something useful with frac1 } and compute using those instances by sending messages The real power of OOP comes from organizing objects into hierarchies, which we’ll see in a future session.

 2003 Joel C. Adams. All Rights Reserved. Calvin CollegeDept of Computer Science(7/10) Object-Oriented Design Rumbaugh’s Object Modeling Technique (OMT):  Write a natural-language description of your system. Our application should display a window containing a textbox in which a user enters their name. When they have entered it, the application should display a personalized greeting for that user.  The nouns (except external ones) are your objects.  If any object cannot be directly represented using predefined types, build a class to create a type for it.  The verbs (except user actions) are your operations.  If any operation cannot be directly performed using predefined operations, build a method (message) to perform it.

 2003 Joel C. Adams. All Rights Reserved. Calvin CollegeDept of Computer Science(8/10) Many designers find it useful to sketch storyboards that show the appearances of their GUIs: OOD: Storyboarding If one storyboard can be reached from another, they are connected by an arrow labeled with the event that triggers the transition… HelloGUI Please enter your name: Enter HelloGUI Please enter your name: Welcome to Java, Jane! Jane

 2003 Joel C. Adams. All Rights Reserved. Calvin CollegeDept of Computer Science(9/10) The Java API The Java Application Programmers Interface (API) provides the definitive word on what classes Java predefines, and what messages instances of those classes accept: Using this, we can build a working application using whatever IDE or tools we have available… I’ll use a text editor and the command-line here; you will use Eclipse that Jeremy will demo for you soon…

 2003 Joel C. Adams. All Rights Reserved. Calvin CollegeDept of Computer Science(10/10) Summary Java is an OO language descended from Smalltalk and C++. Java was designed to allow programs to be downloaded and executed anywhere on the Internet; portability is paramount. In object-oriented languages, much of the programming effort goes into building classes. Objects are instances of classes. Objects communicate with one another by sending messages.