©2007 · Georges Merx and Ronald J. NormanSlide 1 Chapter 3 The Structure and Syntax of Java.

Slides:



Advertisements
Similar presentations
wwwcsif.cs.ucdavis.edu/~jacksoni
Advertisements

IT 325 OPERATING SYSTEM C programming language. Why use C instead of Java Intermediate-level language:  Low-level features like bit operations  High-level.
L3:CSC © Dr. Basheer M. Nasef Lecture #3 By Dr. Basheer M. Nasef.
Object Oriented Programming in JAVA
©2007 · Georges Merx and Ronald J. NormanSlide 1 Chapter 5 Architecture-Driven Component Development.
Client Side Programming Using Java Applet Outcomes: You will be expected to know: – Java Applets and HTML file; –bytecode and platform independent programs;
Chapter 6 Graphical User Interface (GUI) and Object-Oriented Design (OOD)
Java Programming, 3e Concepts and Techniques Chapter 5 Arrays, Loops, and Layout Managers Using External Classes.
Principles of Object-Oriented Software Development The language Java.
Java Syntax Primitive data types Operators Control statements.
Java Programming, 3e Concepts and Techniques Chapter 1 An Introduction to Java and Program Design.
CS-341 Dick Steflik Introduction. C++ General purpose programming language A superset of C (except for minor details) provides new flexible ways for defining.
Introduction to Java CS 331. Introduction Present the syntax of Java Introduce the Java API Demonstrate how to build –stand-alone Java programs –Java.
Review CSC 171 FALL 2004 LECTURE 21. Topics Objects and Classes Fundamental Types Graphics and Applets Decisions Iteration Designing Classes Testing and.
Chapter 1 Introduction.
Variables Chapter 9 - Student Naming, data types, instance variables, math and conversions.
1 Chapter 8 Objects and Classes. 2 Motivations After learning the preceding chapters, you are capable of solving many programming problems using selections,
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.
Copyright © 2009 Pearson Education, Inc. Publishing as Pearson Addison-Wesley Java Software Solutions Foundations of Program Design Sixth Edition by Lewis.
CMSC 341 Introduction to Java Based on tutorial by Rebecca Hasti at
Chapter 6: Graphical User Interface (GUI) and Object-Oriented Design (OOD) J ava P rogramming: Program Design Including Data Structures Program Design.
Programming Principles Data types and Variables. Data types Variables are nothing but reserved memory locations to store values. This means that when.
Introduction to Java Appendix A. Appendix A: Introduction to Java2 Chapter Objectives To understand the essentials of object-oriented programming in Java.
©2007 · Georges Merx and Ronald J. NormanSlide 1 Chapter 1 Introduction to Java in the Context of Software Engineering.
Polymorphism, Inheritance Pt. 1 COMP 401, Fall 2014 Lecture 7 9/9/2014.
INTRODUCTION TO JAVA CHAPTER 1 1. WHAT IS JAVA ? Java is a programming language and computing platform first released by Sun Microsystems in The.
By Nicholas Policelli An Introduction to Java. Basic Program Structure public class ClassName { public static void main(String[] args) { program statements.
Algorithm Programming Bar-Ilan University תשס"ח by Moshe Fresko.
1 Computer Systems -- Introduction  Chapter 1 focuses on:  the structure of a Java application  basic program elements  preparing and executing a program.
Chapter 1: Introducing JAVA. 2 Introduction Why JAVA Applets and Server Side Programming Very rich GUI libraries Portability (machine independence) A.
The Java Programming Language
Lecture 2 Object Oriented Programming Basics of Java Language MBY.
CS 11 java track: lecture 1 Administrivia need a CS cluster account cgi-bin/sysadmin/account_request.cgi need to know UNIX
JAVA Tokens. Introduction A token is an individual element in a program. More than one token can appear in a single line separated by white spaces.
Java Programming, Second Edition Chapter One Creating Your First Java Program.
Liang, Introduction to Java Programming, Eighth Edition, (c) 2011 Pearson Education, Inc. All rights reserved Chapter 8 Objects and Classes.
Java Structure import java_packages; class JavaClass { member variables declarations; void otherMethod( ) { } public static void main(String[]
Lec 6 Data types. Variable: Its data object that is defined and named by the programmer explicitly in a program. Data Types: It’s a class of Dos together.
CS 112 Department of Computer Science George Mason University CS 112 Department of Computer Science George Mason University Final Review Lecture 14.
Applied Computing Technology Laboratory QuickStart C# Learning to Program in C# Amy Roberge & John Linehan November 7, 2005.
An Introduction to Java – Part 1 Dylan Boltz. What is Java?  An object-oriented programming language  Developed and released by Sun in 1995  Designed.
Java™ How to Program, 10/e © Copyright by Pearson Education, Inc. All Rights Reserved.
Chapter 8 Objects and Classes Object Oriented programming Instructor: Dr. Essam H. Houssein.
GUIs Graphical User Interfaces. Everything coming together Known: – Inheritance – Interfaces – Abstract classes – Polymorphism – Exceptions New: – Events.
Liang, Introduction to Java Programming, Fifth Edition, (c) 2005 Pearson Education, Inc. All rights reserved Chapter 6 Objects and Classes.
 In the java programming language, a keyword is one of 50 reserved words which have a predefined meaning in the language; because of this,
SOEN 343 Software Design Section H Fall 2006 Dr Greg Butler
CSI 3125, Preliminaries, page 1 Data Type, Variables.
Developed at Sun Microsystems in 1991 James Gosling, initially named “OAK” Formally announced java in 1995 Object oriented and cant write procedural.
Introduction to Java John Lewis. Course Overview Introduction Object Orientated Programming Java Structure and Syntax Using the Java Platform Advanced.
Spring 2009 Programming Fundamentals I Java Programming XuanTung Hoang Lecture No. 8.
INTRODUCTION CHAPTER #1 Visual Basic.NET. VB.Net General features It is an object oriented language  In the past VB had objects but focus was not placed.
Chapter 1 Java Programming Review. Introduction Java is platform-independent, meaning that you can write a program once and run it anywhere. Java programs.
 Variables are nothing but reserved memory locations to store values. This means that when you create a variable you reserve some space in memory. 
Chapter 10 - Writing Graphical User Interfaces1 Chapter 10 Writing Graphical User Interfaces.
JAVA Programming (Session 2) “When you are willing to make sacrifices for a great cause, you will never be alone.” Instructor: รัฐภูมิ เถื่อนถนอม
1 Lecture # 2. * Introducing Programming with an Example * Identifiers, Variables, and Constants * Primitive Data Types * Byte, short, int, long, float,
Basic Data Types อ. ยืนยง กันทะเนตร คณะเทคโนโลยีสารสนเทศและการสื่อสาร มหาวิทยาลัยพะเยา Chapter 4.
Features of JAVA PLATFORM INDEPENDENT LANGUAGE JAVA RUNTIME ENVIRONMENT (JRE) JAVA VIRTUAL MACHINE (JVM) JAVA APP BYTE CODE JAVA RUNTIME ENVIRONMENT.
CSE S. Tanimoto Java Introduction 1 Java A Programming Language for Web-based Computing.
 It is a pure oops language and a high level language.  It was developed at sun microsystems by James Gosling.
Objects as a programming concept
JAVA MULTIPLE CHOICE QUESTION.
“Form Ever Follows Function” Louis Henri Sullivan
Chapter No. : 1 Introduction to Java.
Internet and Java Foundations, Programming and Practice
CS230 Tutorial Week 3.
Principles of Computer Programming (using Java) Chapter 2, Part 1
Chapter 1: Computer Systems
Constructors, GUI’s(Using Swing) and ActionListner
Presentation transcript:

©2007 · Georges Merx and Ronald J. NormanSlide 1 Chapter 3 The Structure and Syntax of Java

©2007 · Georges Merx and Ronald J. NormanSlide 2 Agenda Learning the language Principles of object orientation Enumerations

©2007 · Georges Merx and Ronald J. NormanSlide 3 Java Resources Extensive resources available in print and on the Internet –Visit –Find the Java Reference and Tutorial pages –Use to find specific information on a topic, e.g. “java jbutton tutorial” –Search for “Java” bookswww.amazon.com

©2007 · Georges Merx and Ronald J. NormanSlide 4 Learning Layout

©2007 · Georges Merx and Ronald J. NormanSlide 5 Learning Connections

©2007 · Georges Merx and Ronald J. NormanSlide 6 Learning the Language Java programming –Syntax Key words, special characters, variable and method names, … –Structure Program navigation Component organization Data structures –Semantics Code logic (  problem solving) Algorithms

©2007 · Georges Merx and Ronald J. NormanSlide 7 Approach Code logic is like human logic, only more rigorous –Attention to detail –Small errors confuse the compiler  errors Design (planning) required Modular approach works best –Low coupling, high cohesion

©2007 · Georges Merx and Ronald J. NormanSlide 8 Other Object-Oriented Programming Languages SmallTalk –Rigorously object-oriented C++ –Extension of C C#, Visual Basic –Microsoft.NET languages Borland Delphi –Successor to Pascal others

©2007 · Georges Merx and Ronald J. NormanSlide 9 Java Compilation Source code  English-like statements Compilation  conversion to bytecodes/native code Bytecodes interpreted/executed by Java runtime during execution –Runtime is platform-specific Platform: processor/OS/Programming env Java Platform: JVM/Java API/Java Language-IDE

©2007 · Georges Merx and Ronald J. NormanSlide 10 Java Primitive Types KeywordDescriptionSize/Format Integers byte Byte-length integer8-bit two's complement short Short integer16-bit two's complement int Integer32-bit two's complement long Long integer64-bit two's complement Real numbers float Single-precision floating point32-bit IEEE 754 double Double-precision floating point64-bit IEEE 754 Other types char A single character16-bit Unicode character boolean A boolean value ( true or false ) true or false Ref.

©2007 · Georges Merx and Ronald J. NormanSlide 11 Java Data Types Primitive types (8) Arrays Classes Interfaces null

©2007 · Georges Merx and Ronald J. NormanSlide 12 Java Syntax (1)

©2007 · Georges Merx and Ronald J. NormanSlide 13 Java Syntax (2) Groups of statements  blocks delineated by braces ({ and })

©2007 · Georges Merx and Ronald J. NormanSlide 14 Class Hierarchy Classes are organized –Hierarchy –Interfaces Objects follow class organization –Abstraction –Composition –Inheritance

©2007 · Georges Merx and Ronald J. NormanSlide 15 Object Instantiation Constructors are methods that are invoked automatically when creating a new object of this class –May be overloaded

©2007 · Georges Merx and Ronald J. NormanSlide 16 Example Class with Constructor

©2007 · Georges Merx and Ronald J. NormanSlide 17 Polymorphism public interface Publication { public String getName(); // … } public class Book implements Publication { // … } public class HardcoverBook extends Book { // … } public class Library { // instance variables public static void main (String args []) { Publication myPublication = new HardcoverBook(); /* create an object of Publication type and initialize it using the constructor HardcoverBook */ System.out.println(myPublication.getname()); // remaining code statements }

©2007 · Georges Merx and Ronald J. NormanSlide 18 Enumerations J2SE 5.0 introduced us to a special class type called enumerations. An enumeration is declared using the enum keyword and provides a powerful, flexible organization for constant variables and their manipulation. public enum FlowType { SEQUENTIAL, PARALLEL, CONCURRENT } FlowType ft = FlowType.PARALLEL; Can be used inside switch statements

©2007 · Georges Merx and Ronald J. NormanSlide 19 Introduction to Graphical User Interfaces: Events

©2007 · Georges Merx and Ronald J. NormanSlide 20 Graphical Controls Buttons, menus, windows, … –Light-weight (Swing), implemented in Java JButton, JRadioButton, JTextField, JFrame, … –Variable look-and-feel: Windows, Unix, Metal, … –Event-driven Model-View-Controller pattern

©2007 · Georges Merx and Ronald J. NormanSlide 21 GUI and Networking Client –Skinny (HTML/JavaScript, AJAX) PUT –Thin (Applet) HTTP, URLConnection (GET, PUT), Sockets –Thick (AWT, Swing) HTTP, Sockets, RMI Server: –Web server with servlets (Tomcat) vs. interpreters –Custom server

©2007 · Georges Merx and Ronald J. NormanSlide 22 J2SE 5.0

©2007 · Georges Merx and Ronald J. NormanSlide 23 Position in Process In this first part of coverage for the Design phase, we focus on the design model –Development of the class hierarchy from the use cases and UML diagrams (1)