Creating Java Applications (Software Development Life Cycle) 1. specify the problem requirements - clarify 2. analyze the problem - Input? Processes? Output.

Slides:



Advertisements
Similar presentations
Introduction to Eclipse. Start Eclipse Click and then click Eclipse from the menu: Or open a shell and type eclipse after the prompt.
Advertisements

Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view class.
 2005 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Written by: Dr. JJ Shepherd
Chapter 6 Introduction to Defining Classes
Inheritance Java permits you to use your user defined classes to create programs using inheritance.
(C) 2010 Pearson Education, Inc. All rights reserved. Java™ How to Program, 8/e.
PACKAGES. PACKAGES IN JAVA A package is a collection of related classes and interfaces in Java Packages help in logical grouping of classes and interfaces.
ITEC200 – Week03 Inheritance and Class Hierarchies.
George Blank University Lecturer. CS 602 Java and the Web Object Oriented Software Development Using Java Chapter 4.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
Fall 2007CS 2251 Inheritance and Class Hierarchies Chapter 3.
OOP in Java Nelson Padua-Perez Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
June 1, 2000 Object Oriented Programming in Java (95-707) Java Language Basics 1 Lecture 3 Object Oriented Programming in Java Language Basics Classes,
CS 201 Functions Debzani Deb.
1 Memory Model of A Program, Methods Overview l Closer Look at Methods l Memory Model of JVM »Method Area »Heap »Stack l Preview: Parameter Passing.
Chapter 10 Classes Continued
OOP in Java Fawzi Emad Chau-Wen Tseng Department of Computer Science University of Maryland, College Park.
INTRODUCTION TO JAVA PROGRAMMING Chapter 1. What is Computer Programming?
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
Singleton Christopher Chiaverini Software Design & Documentation September 18, 2003.
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA ‏ Packages.
Chapter 12 Inheritance and Exceptions Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by S.N. Kamin, D. Mickunas,
220 FINAL TEST REVIEW SESSION Omar Abdelwahab. INHERITANCE AND POLYMORPHISM Suppose you have a class FunClass with public methods show, tell, and smile.
LESSON 2 CREATING A JAVA APPLICATION JAVA PROGRAMMING Compiled By: Edwin O. Okech [Tutor, Amoud University]
Introduction to Object Oriented Programming. Object Oriented Programming Technique used to develop programs revolving around the real world entities In.
Programming in Java Unit 2. Class and variable declaration A class is best thought of as a template from which objects are created. You can create many.
POS 406 Java Technology And Beginning Java Code
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 13 Introduction to Classes.
More on Hierarchies 1. When an object of a subclass is instantiated, is memory allocated for only the data members of the subclass or also for the members.
JAVA: An Introduction to Problem Solving & Programming, 5 th Ed. By Walter Savitch and Frank Carrano. ISBN © 2008 Pearson Education, Inc., Upper.
Java™ How to Program, 10/e © Copyright by Pearson Education, Inc. All Rights Reserved.
JAVA Classes Review. Definitions Class – a description of the attributes and behavior of a set of computational objects Constructor – a method that is.
Classes In C++ 1. What is a class Can make a new type in C++ by declaring a class. A class is an expanded concept of a data structure: instead of holding.
Object Oriented Programming Examples: C++, Java Advantages: 1. reusibility of code 2. ability to adapt (extend) previously written code.
1 CSE1340 Class 4. 2 Objectives Write a simple computer program in Java Use Swing components to build the GUI Use proper naming conventions for classes.
Chapter 10 Defining Classes. The Internal Structure of Classes and Objects Object – collection of data and operations, in which the data can be accessed.
Chapter 6 Introduction to Defining Classes. Objectives: Design and implement a simple class from user requirements. Organize a program in terms of a view.
Summing Up Object Oriented Design. Four Major Components: Abstraction modeling real-life entities by essential information only Encapsulation clustering.
© Copyright 1992–2004 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Chapter 26 - Java Object-Based Programming Outline 26.1Introduction.
Introduction to Java Chapter 7 - Classes & Object-oriented Programming1 Chapter 7 Classes and Object-Oriented Programming.
Lesson 4 Input. JAVA Input JAVA input is not straightforward and is different depending on the JAVA environment that you are using. The reason it is not.
Chapter 5 Introduction to Defining Classes
Chapter 2 Input, Variables and Data Types. JAVA Input JAVA input is not straightforward and is different depending on the JAVA environment that you are.
Inheritance and Class Hierarchies Chapter 3. Chapter 3: Inheritance and Class Hierarchies2 Chapter Objectives To understand inheritance and how it facilitates.
 2005 Pearson Education, Inc. All rights reserved. 1 Introduction to Classes and Objects.
 2005 Pearson Education, Inc. All rights reserved Introduction to Classes and Objects.
Inheritance and Class Hierarchies Chapter 3. Chapter Objectives  To understand inheritance and how it facilitates code reuse  To understand how Java.
Chapter 11: Advanced Inheritance Concepts. Objectives Create and use abstract classes Use dynamic method binding Create arrays of subclass objects Use.
Topic 8Classes, Objects and Methods 1 Topic 8 l Class and Method Definitions l Information Hiding and Encapsulation l Objects and Reference Classes, Objects,
Classes, Interfaces and Packages
Programming in java Packages Access Protection Importing packages Java program structure Interfaces Why interface Defining interface Accessing impln thru.
CSI 3125, Preliminaries, page 1 Packages. CSI 3125, Preliminaries, page 2 Packages Packages are containers for classes Collection of classes Packages.
In this class, we will cover: Overriding a method Overloading a method Constructors Mutator and accessor methods The import statement and using prewritten.
Terms and Rules II Professor Evan Korth New York University (All rights reserved)
OOP Basics Classes & Methods (c) IDMS/SQL News
Object Oriented Programming in Java Habib Rostami Lecture 10.
UMass Lowell Computer Science Java and Distributed Computing Prof. Karen Daniels Fall, 2000 Lecture 10 Java Fundamentals Objects/ClassesMethods.
1 Sections 6.4 – 6.5 Methods and Variables Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
Classes CS 162 (Summer 2009). Parts of a Class Instance Fields Methods.
Chapter 5 Introduction to Defining Classes Fundamentals of Java.
Java Programming: Guided Learning with Early Objects Chapter 9 Inheritance and Polymorphism.
3 Introduction to Classes and Objects.
Inheritance and Polymorphism
Interface.
Java Programming Language
Packages and Interfaces
SPL – PS3 C++ Classes.
Presentation transcript:

Creating Java Applications (Software Development Life Cycle) 1. specify the problem requirements - clarify 2. analyze the problem - Input? Processes? Output expected? 3. design the classes - top down: What are the major subtasks for which - Classes exist that are appropriate? Classes exist that can be modified? New classes must be written? (Write algorithms where needed.) 4. implement the classes - write Java code from design 5. test and verify the program - desk check with examples from all cases of data, then run program to verify. 6. maintain / update the program

A Java application is a collection of classes. 1. An application (or client) class containing main() is required. This tells the reader and the JVM where to start execution. (The order in which all other classes and the methods in them are stored doesn’t matter.) 2. All other classes are supporting classes which do all the work. 3. Each class contains two types of members: data fields and methods. (methods contain the instructions to process the data as needed)

Overview Of A Class Definition private double sqMeter; public double toSqYards() { …} public void readSqMeters() { …} public void displayFabric() { …} } class header public class PieceOfFabric extends Simple GUI{ class name data declaration method definition Is this a client or support class? (Support - there is no main() method.

Sample Java Application public class HelloWorld { public static void main (String args[]){ System.out.println(“Hello World …”); } HelloWorld.java class namerequired for applications predefined methodpredefined class

Method Body {...}{...} public void readSquareMeters() name of method return typescope start of block end of block body / block Instructions to access, modify and/or return data.

Two types of Statements: 1.Declaration - tells the compiler the name (or identifier) of a variable ( a storage location ) the scope (private, protected or public) and the type of data it is permitted to store. private double sqMeters; scopetype name of identifier private - identifier is only accessible by methods in the class

Scope (Visibility Modifiers) Public - accessible to all clients desiring access. Classes are usually public and methods are often public, but not always, but data fields are usually not public. Private - prevents class’s clients from accessing variables directly, thus preventing data fields from being processed in any unpredictable way.

package is a group of related classes stored in directory of same name. if public, private, or protected is omitted, the variable (data field, methods, or class) is accessible ONLY by classes within the same package public class SomeClass {long x, y=10, z; //declare three longs at once } variables x, y, and z are accessible ONLY by classes within the same package because public, private, or protected is omitted (If no package is declared for a class, the Java compiler will put it in the default package - just keep all classes in the same folder.)

Importing a Package An import statement must appear at the top of a file to allow a package of classes defined elsewhere in storage to be used by the program. (If this is not done, each class used must be referenced by the long name: packageName.className) Example: import javax.swing.* ; (this allows use of classes in that package including, JOptionPane which has methods that create windows for user interface)

Extending a class A hierarchy of classes is created by this process, by which code can be reused easily. When a class is extended it is called the superclass (or parent) and the subclass in which the word extend appears in the heading has direct access to its members, while being able to declare its own.

Creating An Object / Instantiation instantiation - creating an object from a class objects are created from classes Shoe class {…} Shoe object class definition

Creating An Object PieceOfFabric aPiece = new PieceOfFabric(); reserve word new allocates memory for the object (aPiece) aPiece - has the address of the object created on the right hand side of the assignment statement memory allocated has the values of the object’s instance variables data typeidentifierconstructor