Chapter 1 INTRODUCTION SYS-ED/ COMPUTER EDUCATION TECHNIQUES, INC.

Similar documents
Chapter 1 GETTING STARTED. SYS-ED/ Computer Education Techniques, Inc.

2 rd class Department of Programming. OOP with Java Programming

From C++ to Java. Duke CPS

Introduction to Visual Basic and Visual C++ Introduction to Java. JDK Editions. Overview. Lesson 13. Overview

Introduction to Programming Using Java (98-388)

Special Topics: Programming Languages

Java Language Basics: Introduction To Java, Basic Features, Java Virtual Machine Concepts, Primitive Data Type And Variables, Java Operators,

[0569] p 0318 garbage

Introduction to Java

Answer1. Features of Java

Programming. Syntax and Semantics

INTRODUCTION 1 AND REVIEW

Zhifu Pei CSCI5448 Spring 2011 Prof. Kenneth M. Anderson

Question No: 1 ( Marks: 1 ) - Please choose one One difference LISP and PROLOG is. AI Puzzle Game All f the given

A brief introduction to C programming for Java programmers

CS321 Languages and Compiler Design I. Winter 2012 Lecture 2

Full file at

CS201- Introduction to Programming Current Quizzes

CS112 Lecture: Primitive Types, Operators, Strings

Modern Programming Languages. Lecture Java Programming Language. An Introduction

Brief Summary of Java

Selected Java Topics

In Java we have the keyword null, which is the value of an uninitialized reference type

Motivation was to facilitate development of systems software, especially OS development.

Question. 1 Features of Java.

Data and Variables. Data Types Expressions. String Concatenation Variables Declaration Assignment Shorthand operators. Operators Precedence

Sample Copy. Not for Distribution.

Crash Course in Java. Why Java? Java notes for C++ programmers. Network Programming in Java is very different than in C/C++

JAVA An overview for C++ programmers

Introduction to Programming (Java) 2/12

AP COMPUTER SCIENCE JAVA CONCEPTS IV: RESERVED WORDS

Java Overview An introduction to the Java Programming Language

CSCI 2010 Principles of Computer Science. Data and Expressions 08/09/2013 CSCI

Assumptions. History

3. Java - Language Constructs I

Fall 2017 CISC124 9/16/2017

Contents. Figures. Tables. Examples. Foreword. Preface. 1 Basics of Java Programming 1. xix. xxi. xxiii. xxvii. xxix

Operating Systems CMPSCI 377, Lec 2 Intro to C/C++ Prashant Shenoy University of Massachusetts Amherst

Objectives. Chapter 2: Basic Elements of C++ Introduction. Objectives (cont d.) A C++ Program (cont d.) A C++ Program

Chapter 2: Basic Elements of C++

Chapter 2: Basic Elements of C++ Objectives. Objectives (cont d.) A C++ Program. Introduction

Weiss Chapter 1 terminology (parenthesized numbers are page numbers)

Limitations of the stack

Exam 1 Prep. Dr. Demetrios Glinos University of Central Florida. COP3330 Object Oriented Programming

CS 112 Introduction to Computing II. Wayne Snyder Computer Science Department Boston University

B.V. Patel Institute of BMC & IT, UTU 2014

Lecture 1: Overview of Java

CPS122 Lecture: From Python to Java last revised January 4, Objectives:

History Introduction to Java Characteristics of Java Data types

Lectures 5-6: Introduction to C

CS313D: ADVANCED PROGRAMMING LANGUAGE

Pointers (continued), arrays and strings

Lectures 5-6: Introduction to C

Seminar report Java Submitted in partial fulfillment of the requirement for the award of degree Of CSE

CSE P 501 Compilers. Java Implementation JVMs, JITs &c Hal Perkins Winter /11/ Hal Perkins & UW CSE V-1

CSI33 Data Structures

Java Application Development

Data Types. Every program uses data, either explicitly or implicitly to arrive at a result.

Chapter 2: Using Data

Programming Language Basics

CPSC 3740 Programming Languages University of Lethbridge. Data Types

Pointers (continued), arrays and strings

Name of subject: JAVA PROGRAMMING Subject code: Semester: V ASSIGNMENT 1

Java and C CSE 351 Spring

Outline. Java Models for variables Types and type checking, type safety Interpretation vs. compilation. Reasoning about code. CSCI 2600 Spring

Data and Expressions. Outline. Data and Expressions 12/18/2010. Let's explore some other fundamental programming concepts. Chapter 2 focuses on:

Where We Are. Lexical Analysis. Syntax Analysis. IR Generation. IR Optimization. Code Generation. Machine Code. Optimization.

PROGRAMMING FUNDAMENTALS

Pace University. Fundamental Concepts of CS121 1

Chapter 1 INTRODUCTION SYS-ED/ COMPUTER EDUCATION TECHNIQUES, INC.

Motivation was to facilitate development of systems software, especially OS development.

CS 11 java track: lecture 1

Lexical Considerations

Kickstart Intro to Java Part I

CS/B.TECH/CSE(OLD)/SEM-6/CS-605/2012 OBJECT ORIENTED PROGRAMMING. Time Allotted : 3 Hours Full Marks : 70

C#: framework overview and in-the-small features

CS11 Java. Fall Lecture 1

VARIABLES AND TYPES CITS1001

a data type is Types

Variables, Constants, and Data Types

Appendix G: Writing Managed C++ Code for the.net Framework

Hacking in C. Pointers. Radboud University, Nijmegen, The Netherlands. Spring 2019

C# and Java. C# and Java are both modern object-oriented languages

Array. Prepared By - Rifat Shahriyar

Chapter 1 Getting Started

Computer Systems A Programmer s Perspective 1 (Beta Draft)

Last week. Data on the stack is allocated automatically when we do a function call, and removed when we return

Program Fundamentals

Project. there are a couple of 3 person teams. a new drop with new type checking is coming. regroup or see me or forever hold your peace

Static Program Analysis Part 1 the TIP language

Why Study Assembly Language?

Managed runtimes & garbage collection. CSE 6341 Some slides by Kathryn McKinley

Managed runtimes & garbage collection

Getting started with Java

Graphical Interface and Application (I3305) Semester: 1 Academic Year: 2017/2018 Dr Antoun Yaacoub

(2½ hours) Total Marks: 75

CONTENTS: Array Usage Multi-Dimensional Arrays Reference Types. COMP-202 Unit 6: Arrays

Introduction To Java. Chapter 1. Origins of the Java Language. Origins of the Java Language. Objects and Methods. Origins of the Java Language

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal

The Java programming environment. The Java programming environment. Java: A tiny intro. Java features

Transcription:

hapter 1 INTRODUTION SYS-ED/ OMPUTER EDUATION TEHNIQUES, IN.

Objectives You will learn: Java features. Java and its associated components. Features of a Java application and applet. Java data types. Java string implementation. Built-in thread components. SYS-ED \OMPUTER EDUATION TEHNIQUES, IN. (JAVA APD1-3.2) h 1: Page i

1 Java Platform The Java Platform is a software platform for delivering and running highly interactive, dynamic, and secure applets and applications on networked computer systems. It sits on top of the other platforms, and executes bytecodes, which are not specific to any physical machine. They are machine instructions for a virtual machine. A program written in the Java Language compiles to a bytecode file that can be run wherever the Java Platform is present, on any underlying operating system. The same file can run on any operating system that is running the Java Platform. Developers can write object-oriented, multithreaded, dynamically linked applications using the Java language. The platform has built-in security, exception handling, and automatic garbage collection. Just-in-time compilers (JIT) are available to speed up execution by converting Java bytecodes into machine language. From within the Java Language, developers can also write and call native methods in, ++ or another language, compiled to a specific underlying operating system-for speed or special functionality. SYS-ED \OMPUTER EDUATION TEHNIQUES, IN. (JAVA APD1-3.2) h 1: Page 1

2 Applets and Applications The Java Platform has two basic parts: Java Virtual Machine Java Application Programming Interface (Java APIApplets and Applications) The Java Platform enables developers to create two different kinds of programs: Applets Applications Applets Applets are programs that require a browser to run. The <applet> tag is embedded in a Web page and names the program to be run. When that page is accessed by a user, either over the Internet or corporate intranet, the applet automatically downloads from the server and runs on the client machine. Because applets are downloaded, they tend to be designed small or modular, to avoid large download times. Applications Applications are programs that do not require a browser to run-they have no built-in downloading mechanism. When an application is called, it runs. In this way, applications are just like programs in other languages. Reminder An applet requires a network to run, while an application does not. Applications have greater freedom in that they have full access to system services. SYS-ED \OMPUTER EDUATION TEHNIQUES, IN. (JAVA APD1-3.2) h 1: Page 2

3 Java Programming Language: Facilities and Foundation The Java programming language: is object-oriented with single inheritance. is statically typed. is multithreaded. is dynamically linked. has automatic garbage collection. The Java programming language syntax is based on and ++. However, there is less redundancy with Java than with these other programming languages. For example, the Java Language has no user-defined operator overloading. For numeric programming, the Java Language has platform-independent data types: array bounds-checking. well-defined IEEE arithmetic. These capabilities provide a solid foundation for writing stable numerical algorithms that give repeatable results. For systems programming, expressions, statements, and operators in the Java Language are in most cases the same as in the language. The Java language facilitates the discovery of bugs early, during development, before the software is released. This is achieved by: strong data typing. automatic garbage collection. array bounds checking. lack of the pointer data type. The Java language has multithreading built in; it is a foundation model based on the synchronization of thread-critical code which will avoid racing or timing problems. SYS-ED \OMPUTER EDUATION TEHNIQUES, IN. (JAVA APD1-3.2) h 1: Page 3

4 Object Oriented Java is an object oriented programming language and has the following advantages: The development cycle is much faster because Java technology is interpreted. The compile-link-load-test-crash-debug cycle is obsolete simply compile and run the programs. Applications are portable across multiple platforms. Once an application has been coded; it will never have to be to ported. The application will then run without modification on multiple operating systems and hardware architectures. Java applications will be efficient because the Java runtime environment manages the memory. Interactive graphical applications have robust performance because multiple concurrent threads of activity in a application are supported by the multithreading built into the Java programming language and runtime platform. Java applications are adaptable to changing environments because code modules can be dynamically downloaded from anywhere on the network. End users can trust that the applications will be secure, even though they're downloading code from all over the Internet. The Java runtime environment has built-in protection against viruses and tampering. SYS-ED \OMPUTER EDUATION TEHNIQUES, IN. (JAVA APD1-3.2) h 1: Page 4

5 Data Types Other than the primitive data types, everything in the Java programming language is an object. The Java programming language follows and ++ fairly closely in its set of basic data types, with a couple of minor exceptions. There are three groups of primitive data types: numeric types character types Boolean types 5.1 Numeric Data Types Integer numeric types are 8-bit byte, 16-bit short, 32-bit int, and 64-bit long. The 8-bit byte data type in Java has replaced the old and ++ char data type. Java places a different interpretation on the char data type. There is no unsigned type specifier for integer data types in Java. Real numeric types are 32-bit float and 64-bit double. A floating point literal value, like 23.79, is considered double by default; it must explicitly be cast to float if you wish to assign it to a float variable. 5.2 haracter Data Types Java language character data is a departure from traditional. Java's char data type defines a sixteen-bit Unicode character. Unicode characters are unsigned 16-bit values that define character codes in the range 0 through 65,535. If a declaration is written such as: char myhar = `Q'; a Unicode (16-bit unsigned value) type is initialized to the Unicode value of the character Q. 5.3 Boolean Data Types Java added a Boolean data type as a primitive type, tacitly ratifying existing and ++ programming practice. A Java boolean variable assumes the value true or false. A Java programming language boolean is a distinct data type; unlike common practice, a Java programming language boolean type can't be converted to any numeric type. SYS-ED \OMPUTER EDUATION TEHNIQUES, IN. (JAVA APD1-3.2) h 1: Page 5

All the familiar and ++ operators apply. 6 Arithmetic and Relational Operators The Java programming language has no unsigned data types, so the >>> operator has been added to the language to indicate an unsigned (logical) right shift. Java also uses the + operator for string concatenation. SYS-ED \OMPUTER EDUATION TEHNIQUES, IN. (JAVA APD1-3.2) h 1: Page 6

7 Arrays In contrast to and ++, the Java programming language arrays are first-class language objects. An array in the Java programming language is a real object with a run-time representation. Arrays can be declared and allocated of any type. Java supports multi-dimensional arrays. An array can be declared with a declaration such as: int mystuff[]; This code states that mystuff is an uninitialized array of Points. At this time, the only storage allocated for mystuff is a reference handle. At some point, the amount of required storage will need to be allocated such as: mystuff = new int[10]; This will allocate an array of ten references. SYS-ED \OMPUTER EDUATION TEHNIQUES, IN. (JAVA APD1-3.2) h 1: Page 7

8 Strings Strings are Java programming language objects, not pseudo-arrays of characters such as in. The Java compiler understands that a string of characters enclosed in double quote signs is to be instantiated as a String object. The declaration: String hello = "Hello world!"; instantiates an object of the String class behind the scenes and initializes it with a character string containing the Unicode character representation of "Hello world!". Java technology has extended the meaning of the + operator to indicate string concatenation. Example: System.out.println("There are " + num + " characters in the file."); This code fragment concatenates the string "There are " with the result of converting the numeric value num to a string, and concatenates that with the string " characters in the file.". Then it prints the result of those concatenations on the standard output. SYS-ED \OMPUTER EDUATION TEHNIQUES, IN. (JAVA APD1-3.2) h 1: Page 8

and ++ programmers explicitly manage memory by: 9 Memory Management and Garbage ollection allocating memory. freeing memory. keeping track of what memory can be freed when. Explicit memory management typically is directly related to: bugs. crashes. memory leaks. poor performance. Java technology removes the burden of memory management load from the programmer. -style pointers, pointer arithmetic, malloc, and free do not exist. Automatic garbage collection is an integral part of Java and its run-time system. Once an object has been allocated the run-time system keeps track of the object's status and automatically reclaims memory when objects are no longer in use, freeing memory for future use. Java technology's memory management model is based on objects and references to objects. Java technology has no pointers. SYS-ED \OMPUTER EDUATION TEHNIQUES, IN. (JAVA APD1-3.2) h 1: Page 9

10 Integrated Thread Synchronization Java technology supports multithreading, both at the language (syntactic) level and via support from its run-time system and thread objects. While other systems have provided facilities for multithreading (usually via "lightweight process" libraries), building multithreading support into the language itself provides the programmer with a much easier and more powerful tool for easily creating thread-safe multithreaded classes. SYS-ED \OMPUTER EDUATION TEHNIQUES, IN. (JAVA APD1-3.2) h 1: Page 10