Lecture 1 Introduction to Java MIT-AITI Ethiopia 2004.

Slides:



Advertisements
Similar presentations
What Is Java? The name Java is a trademark of Sun Microsystems
Advertisements

What is a Computer Program? For a computer to be able to do anything (multiply, play a song, run a word processor), it must be given the instructions.
Introduction To Java Objectives For Today â Introduction To Java â The Java Platform & The (JVM) Java Virtual Machine â Core Java (API) Application Programming.
Client Side Programming Using Java Applet Outcomes: You will be expected to know: – Java Applets and HTML file; –bytecode and platform independent programs;
Object Orientated Programming
Lecture 2: Do you speak Java?. From Problem to Program Last Lecture we looked at modeling with objects! Steps to solving a business problem –Investigate.
Slides prepared by Rose Williams, Binghamton University Chapter 1 Getting Started 1.1 Introduction to Java.
OOP & JAVA. HelloWorld.java /** * The HelloWorld class is an application that * displays "Hello World!" to the standard output. */ public class HelloWorld.
What is an object? Your dog, your desk, your television set, your bicycle. Real-world objects share two characteristics: They all have state and behavior;
How to Create a Java program CS115 Fall George Koutsogiannakis.
How do we make our HelloTester.java program do something? The java in our HelloTester.java file won’t do anything by itself. We need to tell the computer.
Introduction to Java Programming
Introduction to Alice Basics : What is Alice? Object Oriented Definitions What Does it Look Like? Where Can I Use it?
Slide 1 of 40. Lecture A The Java Programming Language Invented 1995 by James Gosling at Sun Microsystems. Based on previous languages: C, C++, Objective-C,
1 Programming Languages Translation  Lecture Objectives:  Be able to list and explain five features of the Java programming language.  Be able to explain.
Lecture 2: Do you speak Java?. From Problem to Program Last Lecture we looked at modeling with objects! Steps to solving a business problem –Investigate.
Introduction to Java.
CSE 1301 J Lecture 2 Intro to Java Programming Richard Gesick.
Getting Started with Java
Java PAL.  Contains the development kit and the runtime environment ( aka the Java Virtual Machine )  Download Link:
IB Computer Science II Paul Bui
Introduction to Java Tonga Institute of Higher Education.
Lecture 1 Introduction to Java MIT- AITI 2004 What is a Computer Program? For a computer to be able to do anything (multiply, play a song, run a word.
CS413: Java Programming language Applications Applets
Basics Programming Concepts. Basics A computer program is a set of instructions to tell a computer what to do Machine language = circuit level language.
An intro to programming. The purpose of writing a program is to solve a problem or take advantage of an opportunity Consists of multiple steps:  Understanding.
Java Lecture 16: Dolores Zage. WWW n Was a method for distributing passive information n added forms and image maps n interaction was only a new way to.
Chapter 1 What is Programming? Lecture Slides to Accompany An Introduction to Computer Science Using Java (2nd Edition) by S.N. Kamin, D. Mickunas, E.
UCSC All rights reserved. No part of this material may be reproduced and sold. 1 IT1202-Fundamentals Of Programming (Using JAVA) Interacting with.
1 Module Objective & Outline Module Objective: After completing this Module, you will be able to, appreciate java as a programming language, write java.
Java Spring PImage Let’s look at the PImage class in ProcessingPImage –What are the fields (i.e., variables)? –What methods are available? –What.
Java Applets. 2 Introduction to Java Applet Programs  Applications are stand alone programs executed with Java interpreter executed with Java interpreter.
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
Java and C# [this is a bonus – it is not a required lesson] ACO101: Introduction to Computer Science.
Java Basics - Prashant Nagaraddi. Features of Java n Java syntax is similar to C/C++ but there are many differences too n Java is strongly typed like.
1 CSC204 – Programming I Lecture 2 Intro to OOP with Java.
POS 406 Java Technology And Beginning Java Code
Java Programming, Second Edition Chapter One Creating Your First Java Program.
Programming Concept Chapter I Introduction to Java Programming.
Compiling and the Java Virtual Machine (JVM). The syntax of Pseudocode is pretty loose –visual validation encourages a permissive approach –emphasized.
Java Applets. 2 Introduction to Java Applet Programs Applications are ___________________ programs –executed with Java interpreter Applet is a small program.
Object Oriented Programming Lecture 3. Introduction  In discussing Java, some items need to be clarified  The Java programming language  The Java virtual.
4-Nov-15 Air Force Institute of Technology Electrical and Computer Engineering Object-Oriented Programming Design Topic 1: The Java Environment Maj Joel.
Lecture.1: Getting Started With Java Jiang (Jen) ZHENG May 9 th, 2005.
Lecture 1. Introduction to Programming and Java MIT- AITI 2003.
1 Software. 2 What is software ► Software is the term that we use for all the programs and data on a computer system. ► Two types of software ► Program.
CSI 3125, Preliminaries, page 1 Compiling the Program.
© 2012 Pearson Education, Inc. All rights reserved types of Java programs Application – Stand-alone program (run without a web browser) – Relaxed.
Objective You will be able to define the basic concepts of object-oriented programming with emphasis on objects and classes by taking notes, seeing examples,
Lesson 1 1 LESSON 1 l Background information l Introduction to Java Introduction and a Taste of Java.
3/5/2002e-business and Information Systems1 Java Java Java Virtual Machine (JVM) Java Application Program Interface (API) HW Kernel API Application Programs.
Java How to Program, 9/e Presented by: José M. Reyes Álamo © by Pearson Education, Inc. All Rights Reserved.
CS 177 Recitation Week 1 – Intro to Java. Questions?
ITP 109 Week 2 Trina Gregory Introduction to Java.
Execution ways of program References: www. en.wikipedia.org/wiki/Integrated_development_environment  You can execute or run a simple java program with.
Introduction to 1. What is Java ? Sun Microsystems Java is a programming language and computing platform first released by Sun Microsystems in The.
Learning Plan 6 Java Programming Intro to Object Oriented Programming.
Instructor: Franklin Amoo. What is a Computer Program? For a computer to be able to do anything (multiply, play a song, run a word processor), it must.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Introduction to Computer Science What is Computer Science? Getting Started Programming.
Introduction to Algorithm. What is Algorithm? an algorithm is any well-defined computational procedure that takes some value, or set of values, as input.
CIS 234: Object-Oriented Programming with Java
Lecture 1b- Introduction
Introduction to.
Introduction to Java Dept. Business Computing University of Winnipeg
IB Computer Science II Paul Bui
Introducing Java.
Road to Object Oriented Programming
Programming language translators
Presentation transcript:

Lecture 1 Introduction to Java MIT-AITI Ethiopia 2004

What is a Computer Program? For a computer to be able to do anything (multiply, play a song, run a word processor), it must be given instructions to do so. A program is a set of instructions that computers can execute. The instructions are written in programming languages such as BASIC, C++, Java, etc.

Recipe Analogy Comparing a computer program to a food recipe Food Recipe a chef writes a set of instructions called a recipe the recipe requires specific ingredients the cook follows the instructions step-by-step the food will vary depending on the amount of ingredients and the cook Computer Program a programmer writes a set of instructions called a program the program requires specific inputs the computer follows the instructions step-by-step the output will vary depending on the values of the inputs and the computer

Running Programs All programs follow a simple format: Input Execution Output Inputs can be from users, files, or other computer programs Outputs can take on many forms: numbers, text, graphics, sound, or commands to other programs

Compiling Programs Computers do not understand programming languages directly. Programs must first be compiled (converted) into machine code that the computer does understand. A compiler is a program that translates a programming language into machine code.

Multiple Compilers Because each operating system (Windows, Macs, Unix) uses its own machine code, most programming languages need a different compiler for each operating system. program compiler Win MAC Unix

Java is different. Java compiler produces bytecode, not machine code. Bytecode can be run on any computer with the Java interpreter installed. Java Program compiler Java Bytecode Win MAC Unix Interpreter Java Interpreter

Advantages and Disadvantages of Java Advantages: Java is platform independent. Once it’s compiled, you can run the bytecode on any machine with a Java interpreter. You do not have to recompile for each platform. Java is safe. Certain common programming bugs and dangerous operations are prevented by the language and compiler. Java standardizes many useful operations like managing network connections and providing graphical user interfaces. Disadvantages: Running bytecode through the interpreter is not as fast as running machine code, which is specific to that platform. Because it is platform independent, it is difficult to use platform specific features (e.g., Windows Taskbar, Quick Launch) in Java. Java interpreter must be installed on the computer in order to run Java programs.

Your First Java Program Open your text-editor and type the following piece of Java code exactly: class HelloWorld { public static void main(String[] args) { System.out.println("Hello World!"); } Save this file as HelloWorld.java (watch capitalization) in the following directory: c:\java

Compiling and Running Your First Program Open the command prompt in Windows To run the program that you just wrote, type at the command prompt: > cd c:\java Your command prompt should now look like this: c:\java> To compile the program that you wrote, you need to run the Java Development Tool Kit Compiler as follows: At the command prompt type: c:\java> javac HelloWorld.java You have now created your first compiled Java program named HelloWorld.class To run your first program, type the following at the command prompt: c:\java> java HelloWorld Although the file name includes the.class extension, this part of the name must be left off when running the program with the Java interpreter.

You’ve created your first Java program!

Object-Oriented Programming OOP Java is an object-oriented programming language. The rest of this lecture is an introduction to the basic principles of object-oriented programming. These principles will become important over the next weeks.

OOP Concepts In object-oriented programming (OOP), programs are organized into objects. The properties of objects are determined by their class. Objects act on each other by passing messages.

Object Definition: An object is a software bundle that has state and behavior. Software objects are often used to model real-world objects. Example: dogs have states (name, color, isHungry, breed) and behaviors (bark, fetch, and wag tail).

Object Examples Example 1: Dogs –States: name, color, breed, and “is hungry?” –Behaviors: bark, run, and wag tail Example 2: Cars –States: color, model, speed, direction –Behaviors: accelerate, turn, change gears

Class Definition: A class is a blueprint that defines the states and the behaviors common to all objects of that type. In the real world, you often have many objects of the same kind: a Poodle, a Spaniel, and a Hound are all dogs. Even though each dog has four legs, and barks, its state and behavior is independent of other dogs.

Message Definition: Software objects interact and communicate with each other by exchanging messages. Example: when you want your dog to gather a herd of goats, you whistle and send him out. He barks at the goats.

Summary of OOP When writing an object-oriented program, we define classes, which describe categories of objects, and the states and behaviors that they have in common. We then instantiate (create) objects of a given class which all share the features of that class. Objects interact with each other by passing messages. You will be creating your own classes and objects soon!