slide1 l.
Skip this Video
Loading SlideShow in 5 Seconds..
Creating Java Applications PowerPoint Presentation
Download Presentation
Creating Java Applications

Loading in 2 Seconds...

play fullscreen
1 / 12

Creating Java Applications - PowerPoint PPT Presentation

  • Uploaded on

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 -

I am the owner, or an agent authorized to act on behalf of the owner, of the copyrighted work described.
Download Presentation

PowerPoint Slideshow about 'Creating Java Applications' - adamdaniel

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.

- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -
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

class name

class header

public class PieceOfFabric extends Simple GUI{

data declaration

private double sqMeter;

public double toSqYards() { …}

public void readSqMeters() { …}

public void displayFabric() { …}


method definition

Is this a client or support class?

(Support - there is no main() method.


Sample Java Application

class name

required for applications

public class HelloWorld {

public static void main (String args[]){

System.out.println(“Hello World …”);



predefined class

predefined method


Method Body


return type

name of method

public void readSquareMeters()






start of block

Instructions to access, modify and/or return data.

body / block

end of block


name of identifier



private double sqMeters;

  • private - identifier is only accessible by methods in the class

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.



(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.


(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.)

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
  • 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

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)


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 object

class definition

Shoe class {…}


Creating An Object

data type


reserve word


PieceOfFabric aPiece = new PieceOfFabric();

  • 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