What is java
Download
1 / 12

What is Java? - PowerPoint PPT Presentation


  • 114 Views
  • Uploaded on

What is Java?. Java technology is both a programming language and a platform ;. Programming Language :. Modern high-level language (Simple, Architecture neutral, Object oriented, Portable, Distributed, High performance, Interpreted, Multithreaded, Robust, Dynamic, Secure).

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

PowerPoint Slideshow about ' What is Java?' - heman


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
What is java
What is Java?

Java technology is both a programming language and a platform;

Programming Language :

Modern high-level language (Simple, Architecture neutral, Object oriented,

Portable, Distributed, High performance, Interpreted, Multithreaded,

Robust, Dynamic, Secure)

The Java programming language is unusual in

that a program is both compiled and interpreted.

Created by Ron Beglieter (based on the Java Tutorial)


Java programming lang
Java Programming Lang.

“Write once, run anywhere”

Generates byteCode

Implementation of the

Java Virtual Machine

(JVM) Spec.


Java platform
Java Platform

The Java platform has two components:

  • The Java Virtual Machine (Java VM)

  • The Java Application Programming Interface (Java API)


Helloworld application
HelloWorld Application

/**

* The HelloWorldApp class implements an application that

* simply displays "Hello World!" to the standard output.

*/

class HelloWorldApp {

public static void main(String[] args) {

System.out.println("Hello World!");

}

}


Hello world app 2

/**

* The HelloWorldApp class implements an application that

* simply displays "Hello World!" to the standard output.

*/

class HelloWorldApp {

public static void main(String[] args) {

System.out.println("Hello World!");

}

}

Hello World App. (2)

HelloWorldApp.java

c:\app> javac HelloWorldApp.java

c:\app> dir

c:\app> javac HelloWorldApp.java

c:\app> dir

HelloWorldApp.java

HelloWorldApp.class

c:\app> javac HelloWorldApp.java

c:\app> dir

HelloWorldApp.java

HelloWorldApp.class

c:\app> java HelloWorldApp

c:\app> javac HelloWorldApp.java

c:\app> dir

HelloWorldApp.java

HelloWorldApp.class

c:\app> java HelloWorldApp

Hello World!

c:\app>

c:\app> javac HelloWorldApp.java

c:\app> javac HelloWorldApp.java

c:\app>

class Robber {

}

class Bank {

}

Bank.java

Robber.java


Object oriented concepts
Object Oriented Concepts

What Is an Object?

An object is a software bundle of related variables and methods. Software objects are often used to model real-world objects you find in everyday life.

What Is a Message?

Software objects interact and communicate with each other using messages.

What Is a Class?

A class is a blueprint or prototype that defines the variables and the methods common to all objects of a certain kind.

What Is Inheritance?

A class inherits state and behavior from its superclass. Inheritance provides a powerful and natural mechanism for organizing and structuring software programs.

What Is an Interface?

An interface is a contract in the form of a collection of method and constant declarations. When a class implements an interface, it promises to implement all of the methods declared in that interface.


An example
An Example

The following example demonstrates OOP (Object Oriented Programming) key concepts as well as the Java language basics

  • public class Spot {

  • public int size;

  • public int x, y;

  • public Spot(int intSize) {

  • size = intSize;

  • x = -1;

  • y = -1;

  • }

  • }

Attributes

Constructor


Example continued
Example (continued)

import java.awt.*;

import java.awt.event.*;

import javax.swing.*;

public class ClickMe extends JPanel implements MouseListener {

private Spot spot = null;

private static final int RADIUS = 7;

public void init() {

addMouseListener(this);

}

…. // full code is supplied

“same” as #include


Example continued1
Example (continued)

public class ClickMe extends JPanel implements MouseListener { … // the missing code is supplied

public static void main(String args[]) {

ClickMe clicker = new ClickMe();

clicker.init();

JFrame frame = new JFrame();

frame.getContentPane().add(clicker,

BorderLayout.CENTER);

frame.pack();

frame.setVisible(true);

}


Example continued2
Example (continued)

public void mousePressed(MouseEvent event) {

if (spot == null) {

spot = new Spot(RADIUS);

}

spot.x = event.getX();

spot.y = event.getY();

repaint();

}


Quiz

Use the API documentation for the Java 2 Platform to answer these questions:

The ClickMe application uses Color.red to set the drawing color to red.

  • What other colors can you get by name like this?

  • How would you specify other colors, like purple?

    Now, use what you learned from the Java API to make the following modifications to the ClickMe Program: (To compile this program, you also need the Spot.java file.)

  • Modify the application to draw a green square instead of a red spot.

  • Modify the application to display your name in purple instead of a red spot.



ad