Lesson 2: First Java Programs. 2.1 Why Java? Java is one of the most popular programming languages in the world. Java is a modern object-oriented programming.

Slides:



Advertisements
Similar presentations
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.
Advertisements

Chapter 2 First Java Programs
Introduction To Java Objectives For Today â Introduction To Java â The Java Platform & The (JVM) Java Virtual Machine â Core Java (API) Application Programming.
Chapter 1 Introduction to JAVA. Why Learn JAVA? Java is one of the fastest growing programming language in the world. Java is one of the fastest growing.
Java.  Java is an object-oriented programming language.  Java is important to us because Android programming uses Java.  However, Java is much more.
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
1/28/2004CSCI 315 Operating Systems Design1 Operating System Structures & Processes Notice: The slides for this lecture have been largely based on those.
1 Programming Languages Translation  Lecture Objectives:  Be able to list and explain five features of the Java programming language.  Be able to explain.
1 Programming & Programming Languages Overview l Machine operations and machine language. l Example of machine language. l Different types of processor.
1. 2 Chapter 1 Introduction to Computers, Programs, and Java.
01 Introduction to Java Technology. 2 Contents History of Java What is Java? Java Platforms Java Virtual Machine (JVM) Java Development Kit (JDK) Benefits.
LESSON 1 INTRODUCTION Compiled By: Edwin O. Okech [Tutor, Amoud University] JAVA PROGRAMMING.
Getting Started with Java
Java PAL.  Contains the development kit and the runtime environment ( aka the Java Virtual Machine )  Download Link:
Chapter 2 First Java Programs
Getting Started What is Java? A programming language –Fully buzzword-compliant: A simple, object oriented, distributed, interpreted, robust, secure,
1 CSC 551: Web Programming Spring 2004 Java Overview  Design goals & features  platform independence, portable, secure, simple, object-oriented, … 
Computer Programming 12 Mr. Jean March 3 rd, 2014.
1.1 History of Computers 1940s: The ENIAC was one of the world’s first computers. Large stand-alone machine Used large amounts of electricity Contained.
Introducing Java.
Introduction to Java Programming with JBuilder 4
© The McGraw-Hill Companies, 2006 Chapter 1 The first step.
+ 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.
Ch 1. Introduction Dr. Bernard Chen Ph.D. University of Central Arkansas Spring 2012.
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
Lesson 2: First Java Programs
Java Workshop for Teachers May 6, 2005 A Brief Look at the Java Programming Language.
Sadegh Aliakbary Sharif University of Technology Spring 2011.
UNIVERSITI TENAGA NASIONAL “Generates Professionals” CHAPTER 4 : Part 2 INTRODUCTION TO SOFTWARE DEVELOPMENT: PROGRAMMING & LANGUAGES.
 Java Programming Environment  Creating Simple Java Application  Lexical Issues  Java Class Library.
CMSC 202 Computer Science II for Majors Object-Oriented Programming.
1 Chapter 2 First Java Programs Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
Computer Programming 12 Mr. Jean March 19 th, 2013.
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.
Lesson 2: First Java Programs. Objectives: –Discuss why Java is an important programming language. –Explain the Java virtual machine and byte code. –Choose.
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.
POS 406 Java Technology And Beginning Java Code
Programming Concept Chapter I Introduction to Java Programming.
CS 3131 Introduction to Programming in Java Rich Maclin Computer Science Department.
CHAPTER 3 GC Java Fundamentals. 2 BASICS OF JAVA ENVIRONMENT  The environment  The language  Java applications programming Interface API  Various.
What Is Java? According to Sun in a white paper: Java: A simple, object-oriented, network-savvy, interpreted, robust, secure, architecture-neutral, portable,
National Taiwan University Department of Computer Science and Information Engineering National Taiwan University Department of Computer Science and Information.
CSE S. Tanimoto Java Introduction 1 Java A Programming Language for Web-based Computing with Graphics.
We will talking about story of JAVA language. By Kristsada Songpartom.
Mini University July, 2005 A Little Taste of Java (but don’t tell your folks) (they might think there’s caffeine involved)
CT1513 Introduction To java © A.AlOsaimi.
Object Oriented Programming Examples: C++, Java Advantages: 1. reusibility of code 2. ability to adapt (extend) previously written code.
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.
Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and web applications Very rich GUI libraries Portability (machine independence) A real Object.
© 2012 Pearson Education, Inc. All rights reserved types of Java programs Application – Stand-alone program (run without a web browser) – Relaxed.
©2016 Pearson Education, Inc. Upper Saddle River, NJ. All Rights Reserved. CSC 110 – INTRO TO COMPUTING - PROGRAMMING Overview of Programming.
Lesson 1 1 LESSON 1 l Background information l Introduction to Java Introduction and a Taste of Java.
ITP 109 Week 2 Trina Gregory Introduction to Java.
Introduction to Programming 1 1 2Introduction to Java.
Programming Languages Concepts Chapter 1: Programming Languages Concepts Lecture # 4.
Programming 2 Intro to Java Machine code Assembly languages Fortran Basic Pascal Scheme CC++ Java LISP Smalltalk Smalltalk-80.
Chapter 2 First Java Programs Fundamentals of Java.
1 Sections Java Virtual Machine and Byte Code Fundamentals of Java: AP Computer Science Essentials, 4th Edition Lambert / Osborne.
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Object-Oriented Programming Using Java
GC101 Introduction to computer and program
Programming Language Hierarchy, Phases of a Java Program
Chapter 1 Introduction to Computers, Programs, and Java
Text by: Lambert and Osborne
Chapter 2 First Java Programs
Hands-on Introduction to JAVA
(Computer fundamental Lab)
Presentation transcript:

Lesson 2: First Java Programs

2.1 Why Java? Java is one of the most popular programming languages in the world. Java is a modern object-oriented programming language. Java has benefited by learning from the less desirable features of early object-oriented programming languages.

2.1 Why Java? Java is ideally suited to develop distributed, network-based applications because it: –Enables the construction of virus-free, tamper-free systems (security) –Supports the development of programs that do not overwrite memory –Has little or no failure rate (robust) –Yields programs that can be run on different types of computers without change (portable)

2.1 Why Java? Java supports advanced programming concepts such as threads. –A thread is a process that can run concurrently with other processes. Java resembles C++, the world’s most popular industrial strength programming language. Java however, runs more slowly than most modern programming languages.

2.2 The Java Virtual Machine and Byte Code Java compilers translate Java into pseudomachine language called java byte code. To run java byte code on a particular computer, a Java virtual machine (JVM) must be installed.

2.2 The Java Virtual Machine and Byte Code A Java virtual machine is a program that acts like a computer. It is called an interpreter. Disadvantage: –Runs more slowly than an actual computer To combat slower processing, some JVMs translate code when first encountered. This is known as just-in-time compilation (JIT).

2.2 The Java Virtual Machine and Byte Code Advantages: –Portability. Any computer can run Java byte code. –Applets. Applets are small Java programs already translated into byte code. Applets run in a JVM incorporated in a web browser Applets can be decorative (like animated characters on a web page.) Applets can be practical (like continuous streams of stock market quotes.) –Security. It is possible to limit the capabilities of a Java program since it runs inside a virtual machine.

2.3 Choosing a User Interface Style There are two types of user interfaces available to use to create Java programs. –Graphical User Interface (GUI) –Terminal I/O interface Figure 2-1 illustrates both interfaces used to create the same program.

2.3 Choosing a User Interface Style

There are 3 reasons for beginning with terminal I/O: –It is easier to implement than a GUI –There are programming situations that require terminal I/O –Terminal-oriented programs are similar in structure to programs that process files of sequentially organized data. (What is learned here is easily transferred to that setting.)

2.4 Hello World Figure 2-2 displays the results of a small Java program, entitled “hello world”

2.4 Hello World A program is a sequence of instructions for a computer. The following is the bulk of instructions, or source code, for the “hello world” program.

2.4 Hello World Sending messages to objects always takes the following form:. ( ) The period between the object name and the message is called a method selector operator.

2.4 Hello World The original “hello world” program needs to be embedded in a larger framework defined by several additional lines of code, in order to be a valid program.

Program Framework public class { public static void main(String [ ] args) {... place statements here... * ( Each statement must end with a ; ) } * Notice the open and closed braces ( { } ).