Introduction to Java CSIS 3701: Advanced Object Oriented Programming.

Slides:



Advertisements
Similar presentations
Date: Subject:Distributed Data Processing Name:Maria Br ü ckner.
Advertisements

Lab Information Security Using Java (Review) Lab#0 Omaima Al-Matrafi.
Object Oriented Programming in JAVA
Data Types in Java Data is the information that a program has to work with. Data is of different types. The type of a piece of data tells Java what can.
Lab#1 (14/3/1431h) Introduction To java programming cs425
Java: History and Introduction (Lecture # 1). History… Java – Based on C and C++ – Developed in 1991 for intelligent consumer electronic devices – Green.
Introduction to Java Kiyeol Ryu Java Programming Language.
Prepared By E.Musa Alyaman1 Chapter 2 The Java Overview.
Outline Java program structure Basic program elements
Introduction to Java CS 331. Introduction Present the syntax of Java Introduce the Java API Demonstrate how to build –stand-alone Java programs –Java.
Netprog 2002 Java Intro1 Crash Course in Java Based on notes from D. Hollinger Based in part on notes from J.J. Johns also: Java in a Nutshell Java Network.
Lecture 1: Overview of Java. What is java? Developed by Sun Microsystems (James Gosling) A general-purpose object-oriented language Based on C/C++ Designed.
CMSC 341 Introduction to Java Based on tutorial by Rebecca Hasti at
Java Security Updated May Topics Intro to the Java Sandbox Language Level Security Run Time Security Evolution of Security Sandbox Models The Security.
Programming in Java; Instructor:Moorthy Introduction, Objects, Classes, Libraries1 Programming in Java Introduction.
JAVA v.s. C++ Programming Language Comparison By LI LU SAMMY CHU By LI LU SAMMY CHU.
CSC 142 A 1 CSC 142 Introduction to Java [Reading: chapter 0]
Introduction to Java CSIS 3701: Advanced Object Oriented Programming.
Java Security. Topics Intro to the Java Sandbox Language Level Security Run Time Security Evolution of Security Sandbox Models The Security Manager.
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
Java. Why Java? It’s the current “hot” language It’s almost entirely object-oriented It has a vast library of predefined objects It’s platform independent.
CSCI 224 Introduction to Java Programming. Course Objectives  Learn the Java programming language: Syntax, Idioms Patterns, Styles  Become comfortable.
Java Introduction Lecture 1. Java Powerful, object-oriented language Free SDK and many resources at
DEPARTMENT OF COMPUTER SCIENCE & TECHNOLOGY FACULTY OF SCIENCE & TECHNOLOGY UNIVERSITY OF UWA WELLASSA 1 CST 221 OBJECT ORIENTED PROGRAMMING(OOP) ( 2 CREDITS.
INTRODUCTION TO JAVA CHAPTER 1 1. WHAT IS JAVA ? Java is a programming language and computing platform first released by Sun Microsystems in The.
University of Houston-Clear Lake Proprietary© 1997 Evolution of Programming Languages Basic cycle of improvement –Experience software difficulties –Theory.
Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and Server Side Programming Very rich GUI libraries Portability (machine independence) A.
INTRODUCTION TO JAVA. Introduction to Java Java programming language ◦ Object-Oriented Programming ◦ Compiled to byte code of JVM Java virtual machine.
Lecture 2 Object Oriented Programming Basics of Java Language MBY.
Introduction to Computer Systems and the Java Programming Language.
Lecture :2 1.  DEFENTION : Java is a programming language expressly designed for use in the distributed environment of the Internet. It was designed.
Java means Coffee Java Coffee Beans The name “JAVA” was taken from a cup of coffee.
Basics of Java IMPORTANT: Read Chap 1-6 of How to think like a… Lecture 3.
CPRG 215 Introduction to Object-Oriented Programming with Java Module 1-Introduction to Java Topic 1.1 Basics of Java Produced by Harvey Peters, 2008 Copyright.
Introduction to java Prepared By:-Pragnesh Patel Lect. In Computer Dept. NSIT,Jetalpur 1.
Netprog: Java Intro1 Crash Course in Java. Netprog: Java Intro2 Why Java? Network Programming in Java is very different than in C/C++ –much more language.
 JAVA Compilation and Interpretation  JAVA Platform Independence  Building First JAVA Program  Escapes Sequences  Display text with printf  Data.
Java Simple Types CSIS 3701: Advanced Object Oriented Programming.
1 Introduction to Java. 2 What is Java? A programming language. A platform –A virtual machine (JVM) definition. –Runtime environments in diverse hardware.
Fall 2015CISC124 - Prof. McLeod1 CISC124 Have you filled out the lab section survey? (As of last night 54 left to fill out the survey.) TA names have been.
CT1513 Introduction To java © A.AlOsaimi.
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.
Core Java Introduction Byju Veedu Ness Technologies httpdownload.oracle.com/javase/tutorial/getStarted/intro/definition.html.
Java Programming, Second Edition Chapter Two Using Data Within a Program.
School of Computer Science & Information Technology G6DICP - Lecture 4 Variables, data types & decision making.
Today… “Hello World” ritual. Brief History of Java & How Java Works. Introduction to Java class structure. But first, next slide shows Java is No. 1 programming.
How to execute Program structure Variables name, keywords, binding, scope, lifetime Data types – type system – primitives, strings, arrays, hashes – pointers/references.
Java – in context Main Features From Sun Microsystems ‘White Paper’
Getting Started With Java September 22, Java Bytecode  Bytecode : is a highly optimized set of instructions designed to be executed by the Java.
Spring 2009 Programming Fundamentals I Java Programming XuanTung Hoang Lecture No. 8.
Chapter 1 Java Programming Review. Introduction Java is platform-independent, meaning that you can write a program once and run it anywhere. Java programs.
Java Basics. Tokens: 1.Keywords int test12 = 10, i; int TEst12 = 20; Int keyword is used to declare integer variables All Key words are lower case java.
Review A program is… a set of instructions that tell a computer what to do. Programs can also be called… software. Hardware refers to… the physical components.
Features of JAVA PLATFORM INDEPENDENT LANGUAGE JAVA RUNTIME ENVIRONMENT (JRE) JAVA VIRTUAL MACHINE (JVM) JAVA APP BYTE CODE JAVA RUNTIME ENVIRONMENT.
Object Oriented Programming Lecture 2: BallWorld.
Spring 2006 Special Topics in Computer Engineering: Java Intro 1 Crash Course in Java Based on notes from D. Hollinger Based in part on notes from J.J.
SESSION 1 Introduction in Java. Objectives Introduce classes and objects Starting with Java Introduce JDK Writing a simple Java program Using comments.
 It is a pure oops language and a high level language.  It was developed at sun microsystems by James Gosling.
Applications Active Web Documents Active Web Documents.
Object Oriented Programming in
1. Introduction To JAVA.
JAVA MULTIPLE CHOICE QUESTION.
Introduction to.
Internet and Java Foundations, Programming and Practice
Java programming lecture one
C Basics.
Units with – James tedder
Units with – James tedder
(Computer fundamental Lab)
Java History, Editions, Version Features
Presentation transcript:

Introduction to Java CSIS 3701: Advanced Object Oriented Programming

Java Background Original purpose: web page applets –Executable/dynamic applications running on web page –No longer main use, but affected language design Server applet Client browser requested by browser copy downloaded to browser applet Java code executed on client computer

Platform Independence Java applet must run on any client –Different OS, architecture, etc.  different machine code –Cannot compile applet to single executable used by all Stage 1: Java source code compiled to “byte code” –Code for an abstract “Java virtual machine” (JVM) Hello.java Source code (must end in.java ) Hello.class Byte code stored on server

Platform Independence Stage 2: JVM on client runs “byte code” –Converted to native machine code line-by line and executed on the fly –JVM can be: Part of browser Built into NetBeans Run separately from command line ( java Hello.class ) Built directly into chip (mobile devices) browser applet Line 1 Line 2 Line 3 Line 4 … Client JVM processor convert and execute

Security and Safety Applet = unknown code running on your computer! –How to prevent malicious applets? Applets vs. Applications –Applets not allowed access to local files, network, etc. –Application: separate standalone process not run in browser

Security and the Sandbox All Java programs execute in restricted area of memory (the “sandbox”) No explicit pointers –int *ptr = 100; // outside sandbox –*ptr = 0; // overwrite that memory Array bounds checking –int A[100]; –A[ ] = 0; // outside sandbox

Safety and Exception Handling Java programs cannot “crash” to OS Exceptions caught and handled within JVM –Browser/NetBeans/etc. notified –Can handle as needed (error message displayed, etc.) applet JVM int x = 0/0; ArithmeticException thrown ;

Tradeoffs Many tradeoffs in language design –No “best” choices –Different languages make different choices Portability vs. Speed –“On the fly” interpretation slower than direct execution of machine code Safety vs. Speed –Array bounds checking –Exception handling Require extra time

Basic Java Syntax Java syntax mostly same as C++ –Java developed by C++ programmers Examples –Lines/blocks: ; {} –Control structures: if else for while switch … –Operators: = + - * / = … == != > = <= && || … –Comments: /* */ //

Simple Types Numeric types: –int 32 bits –short 16 bits –byte 8 bits –long 64 bits –float 32 bits, ~7 digits after decimal –double 64 bits, ~13 digits after decimal Defined standard in Java language

Simple Types Boolean type –keywords true and false –Example: boolean b = true; Char type –16-bit Unicode for international purposes –Examples: char c1 = ‘A’; char c2 = ‘\u3218’ –Numeric representation of non-ASCII character Tradeoff: memory vs. internationalization

Type Conversion int x = 3.7; –What does this do? Weak typing (C/C++) –Language attempts to convert one type to another –3.7 truncated to 3 and stored in x Strong typing (Java) –Must be no possible ambiguity or information loss –Otherwise syntax error

Type Conversion Other examples: –if (1) {…} Condition must be true or false –long y; int x; Possible information loss x = y; Must explicitly cast to less precise type –int x = (int)3.7; Tradeoff: safety vs. convenience

Constants and Types What type is the number 3 ? The number 3.7 ? –Number without decimal is int. –Number with decimal is double. Possible type conversion problems Example: float y = 3.7; –Syntax error – trying to store double as float –Java hack: Follow constant with f float y = 3.7f;