Chapter 1 FOUNDATIONS OF JAVA

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

Understand and appreciate Object Oriented Programming (OOP) Objects are self-contained modules or subroutines that contain data as well as the functions.
Agenda Definitions Evolution of Programming Languages and Personal Computers The C Language.
In Review JAVA C++ GUIs - Windows Webopedia.com.
Introduction To Java Objectives For Today â Introduction To Java â The Java Platform & The (JVM) Java Virtual Machine â Core Java (API) Application Programming.
CSCE 145: Algorithmic Design I Chapter 1 Intro to Computers and Java Muhammad Nazmus Sakib.
Java: History and Introduction (Lecture # 1). History… Java – Based on C and C++ – Developed in 1991 for intelligent consumer electronic devices – Green.
1 Fall 2008ACS-1903 Chapter 1 Topics Java History Java Programs Why Program? Computer Systems: Hardware and Software Programming Languages What Is a Program.
Java Programming, 3e Concepts and Techniques Chapter 1 An Introduction to Java and Program Design.
For more Lectures and Notes Visit
Introduction to Java.
Session-02. Objective In this session you will learn : What is Class Loader ? What is Byte Code Verifier? JIT & JAVA API Features of Java Java Environment.
L EC. 01: J AVA FUNDAMENTALS Fall Java Programming.
LESSON 1 INTRODUCTION Compiled By: Edwin O. Okech [Tutor, Amoud University] JAVA PROGRAMMING.
JAVA v.s. C++ Programming Language Comparison By LI LU SAMMY CHU By LI LU SAMMY CHU.
Computer Programming-1 CSC 111 Chapter 1 : Introduction.
Java Programming, 2E Introductory Concepts and Techniques Chapter 1 An Introduction to Java and Program Design.
CSC 142 A 1 CSC 142 Introduction to Java [Reading: chapter 0]
+ 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.
Sadegh Aliakbary Sharif University of Technology Spring 2011.
Java Beserkers Group 4. Start of Java Development began on June of 1991 by a group of computer scientist at the Sun Mircrosystems Company Development.
CMSC 202 Computer Science II for Majors Object-Oriented Programming.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Programming Languages Machine.
Introduction to Programming Languages. Problem Solving in Programming.
Chapter 34 Java Technology for Active Web Documents methods used to provide continuous Web updates to browser – Server push – Active documents.
University of Houston-Clear Lake Proprietary© 1997 Evolution of Programming Languages Basic cycle of improvement –Experience software difficulties –Theory.
Liang, Introduction to Java Programming, Sixth Edition, (c) 2007 Pearson Education, Inc. All rights reserved Chapter 1 Introduction to.
Module Overview n Module Title: OO Programming n Module Code: MIT3446 n Module Value: 3.0 n Duration: 15 weeks n Class-Contact Hours: Lecture15 hrs n Lab/Tutor30hrs.
Java Programming, Second Edition Chapter One Creating Your First Java Program.
Chapter 1 Section 1.1 Introduction to Java Slides prepared by Rose Williams, Binghamton University Kenrick Mock, University of Alaska Anchorage.
What Is Java? According to Sun in a white paper: Java: A simple, object-oriented, network-savvy, interpreted, robust, secure, architecture-neutral, portable,
 Programming Language  Object Oriented Programming  JAVA – An Introduction  JAVA Milestones  JAVA Features.
CT1513 Introduction To java © A.AlOsaimi.
Java Basics 1 Brief History of Java and Overview of Langauge.
Introduction Mehdi Einali Advanced Programming in Java 1.
Introduction to OOP CPS235: Introduction.
Lesson 1 1 LESSON 1 l Background information l Introduction to Java Introduction and a Taste of Java.
Lecture1 Instructor: Amal Hussain ALshardy. Introduce students to the basics of writing software programs including variables, types, arrays, control.
Introduction to JAVA Programming
Sung-Dong Kim, Dept. of Computer Engineering, Hansung University Java - Introduction.
Fundamental of Java Programming (630002) Unit – 1 Introduction to Java.
Introduction to Algorithm. What is Algorithm? an algorithm is any well-defined computational procedure that takes some value, or set of values, as input.
Chapter 1 Coding Introduction.
Software Development Environment
Object Oriented Programming in
Java Programming: From the Ground Up
Visit for more Learning Resources
Done By: Ashlee Lizarraga Ricky Usher Jacinto Roches Eli Gomez
Topics Introduction Hardware and Software How Computers Store Data
Unit-1 JAVA Programming.
Chapter 1 Introduction to Computers, Programs, and Java
Lecture 1: Introduction to JAVA
The Java Programming Language
Introduction to Computers and Java
Java programming lecture one
Introduction Enosis Learning.
An Overview of Java.
PROGRAMMING IN JAVA. INTRODUCTION TO JAVA  Java is a general purpose computer programming language that is concurrent, class-based, object- oriented.
Introduction Enosis Learning.
Chapter 1 Coding Introduction.
Advanced Programming Fall 2017.
Topics Introduction Hardware and Software How Computers Store Data
Introduction CSC 111.
(Computer fundamental Lab)
Java Programming Introduction
Java History, Editions, Version Features
By Rajanikanth B Overview Of Java By Rajanikanth B
CSC 142 Introduction to Java [Reading: chapters 1 & 2]
Java Evolution Java History. Java Features.
Outcome of the Lecture Upon completion of this lecture you will be able to understand Fundamentals and Characteristics of Java Language Basic Terminology.
Presentation transcript:

Chapter 1 FOUNDATIONS OF JAVA Java Programming Chapter 1 FOUNDATIONS OF JAVA

Agenda 1.1 Computer Systems 1.2 Programming Languages 1.3 Stage for Java 1.4 Origin of Java 1.5 Challenges of Java 1.6 Java Features 1.7 Java Program Development 1.8 Object-oriented Programming

1.1 Computer Systems A computer is an electronic machine that accepts data in a variety of formats, as input The basic components of computers are Internal memory Processor Storage devisés Peripheral devices Communication devices

Computer Systems (Contd.)

Computer Systems (Contd.) The Internal Memory represented by Random Access Memory (RAM) is used to store instructions and data. The Processor, earlier known as Central Processing Unit (CPU), is capable of controlling the entire computer system. The instructions stored in the internal memory are fetched, decoded and executed by the processor.

Computer Systems (Contd.) Calculations and comparisons are done in the ALU. Peripheral devices, also called input/output devices, communicate between the user and the processor. Storage devices are termed non-volatile or stable memory, and are used to store instructions and data. Communication devices connect the computer to other machines using LAN/WAN. A computer may be connected to the Internet easily via a modem using a telephone line.

1.2 Programming Languages A program is a collection of instructions executed by a computer to perform a specific job. Programs stored in the computer’s internal storage are executed in the processor and the result is displayed in the output device. Programming is the process of taking an algorithm and encoding it into a notation using a programming language. It provides language constructs to solve the problem and offers data types to handle data.

Programming Languages (Contd.) Programming languages are classified into various types Machine Level Language (MLL) Assembly Level Language (ALL) High Level Language (HLL) Computers can understand 0 and 1 and MLL is also written using 0 and 1. Hence the processor can understand only MLL.

Programming Languages (Contd.) ALL - the instructions are represented as two parts, but the operation part is written in symbolic operation code such as ADD, SUB, etc. The data part is accessed symbolically from the processor registers or memory. HL languages are called procedural languages. Compiler, which is software that translates HLL programs into MLL programs.

Programming Languages (Contd.) Two leading approaches to programming, or programming paradigms Procedural Programming Object-Oriented Programming (OOP) Procedural approach gives a sequence of organized steps and processes within its programming context to build a program. OOP solves a problem using objects. An object is a component that knows how to perform certain tasks and how to interact with other parts of the program.

1.3 Stage for Java The main reasons for the popularity of Java are the platform independence and the vibrant and interactive web environment it provides. Java derives its syntax from C and object-orientation from C++. Similarities and differences – C/C++ and Java C++ is platform dependent while Java is platform independent. C++ was used mainly for systems programming, but Java is used for application programs. C++ uses the goto statement, while Java does not support the goto statement.

Stage for Java (Contd.) Similarities and differences – C/C++ and Java C++ supports multiple inheritances, but Java does not support multiple inheritances C++ supports operator overloading, while Java does not support operator overloading. C++ supports pointers, but Java supports pointers implicitly. C++ programs are only compiled but in Java, the programs are first compiled and then interpreted. C++ support call by value and call by reference, but Java supports only call by value.

Stage for Java (Contd.) Similarities and differences – C/C++ and Java In C++ there is no provision for threads but Java provides built-in support for thread handling Memory de-allocation in C++ is done by calling its destructors. In Java, that is taken care of by Garbage Collection. A few features of C++ are not supported by Java for security purposes, because the language is for the Internet.

1.4 Origin of Java The Internet is a collection of various computers on different platforms and thus the need was felt for a language to handle communication between computers across platforms. Java was developed by a team from Sun Microsystems in 1991, led by James Gosling. Java was initially designed for programming home appliances such as washing machines, microwave ovens, televisions, etc.

Origin of Java (Contd.) C ++ was taken as the model for designing a new language, which was called “Oak”. There were two challenges facing the development team. The first was that the appliances were controlled by various types of processors chip and there was need for a common language to work on these processors. The second was that the compiler to be used in the home appliances needed a huge investment. The programs developed for these machines were to be executed with the help of a compiler and executed to control the appliances.

Origin of Java (Contd.) The development team adopted a two-step process. The first step was to translate the programs written for the appliances to an intermediate code, which was the same for all appliances. The second step was to execute the intermediate code in a step-by-step manner for a particular appliance. Programs written for one computer may not work on another computer. In that context, portability is a great asset for programming. Writing a program for one computer and executing it on another is called portability.

Origin of Java (Contd.) The two-step process was adopted for programming. The first step is that the program written is translated by a Java compiler into standardized machine language called bytecode which is the same for all computers. The bytecode is a machine-independent intermediate code. The second step is to translate this bytecode into machine language using an interpreter for a particular computer. The bytecode is interpreted and executed on any platform having a Java Virtual Machine (JVM).

Origin of Java (Contd.) To run the bytecode, it needs a JVM that serves as a language interpreter. The JVM reads the bytecode instructions and translates, instruction by instruction, into machine language codes that are executed by a particular computer. Java programs are translated by the compiler into bytecode, which is common to all types of computers. The JVM for Windows interprets the bytecode for Windows.

Origin of Java (Contd.)

Origin of Java (Contd.) “Oak” had already been claimed and they changed the name to Java. Java is now owned by Oracle Corporation. In 1994, Patrick Naughton and Jonathan Payne developed HotJava, which is a web browser to execute Java programs in the Internet. That is why Java is known as the programming language for the Internet.

Origin of Java (Contd.) There are two types of programs in Java, namely, applications and applets. The standalone program written for any common problem is called an application and it does not need a browser to run. The program executed in a browser is called an applet. An applet is a program designed to be executed within a Java compatible browser or applet viewer.

1.5 Challenges of Java Security Portability The applet executed by the JVM will not allow access to authorized parts of the computer. Hence, an applet will not harm the computer and the fact that security is not broken is an important feature of Java. Portability Portability means being able to write a program once and run it anywhere. It facilitates programs being executed on any platform without making changes to the code. Java is portable, which makes its applications run on any platform.

Challenges of Java (Contd.) Platform Independence Java is not compiled into a platform-specific code; rather, it results in platform independent bytecode. The bytecode is supported by any computer which has JVM installed, which makes Java a platform independent language.

1.6 Java Features Java Simple Object-oriented Compiled Architectural neutral Multi-threaded Garbage collection Robust Extensible language

1.7 Java Program Development JDK is an open source and can be installed from the url www.oracle.com/technetwork/java/javase/downloads/index.html. But to begin learning Java, it may be better to use JDK from Oracle with a simple text editor like Notepad. After learning Java to implement application or applet use NetBeans IDE, which can be downloaded from http://netbeans.org.

Java Program Development (Contd.)

Object-oriented Programming Object is a concept or abstract or thing with boundaries and gives meaning to the problem. Objects have two purposes: to promote understanding of the real world to provide practical basics for implementation. An object contains data and methods which manipulate this data. The class provides a template for the objects.

Object-oriented Programming (Contd.)

Object-oriented Programming (Contd.)

Object-oriented Programming (Contd.)

Object-oriented Programming (Contd.) In OOP, the data is protected and can be accessed only by the intended users, that is, an unauthorized user cannot use the data in an object. OOP involves three main concepts that are the backbone of OOP: Encapsulation Inheritance Polymorphism

Encapsulation Encapsulation allows the programmer to hide inside the object both the data and the methods that act on that data. Encapsulation is the concept of binding data and methods together and it prevents unauthorized access. To access the data, developers use controlled access through the method which acts as an interface.

Inheritance Inheritance provides reusability by defining a new class from an already defined class. It allows creating a class that is similar to a previously defined class; the new class can also have its own data members and methods. The new class inherits its characteristics from the defined base class and the new class also has its own members. In OOP, a base class is seen as a parent and a derived class as a child.

Polymorphism Polymorphism is the ability of an object to take on many forms. Polymorphism is derived from two Greek words: poly and morphs. The word “poly” means many and “morphs” means forms. So polymorphism means many forms. Polymorphism principle is implemented with method overriding concept of java.

Polymorphism (Contd.) Polymorphism principle is divided into two sub-principles. They are: Static polymorphism Dynamic polymorphism Static binding is also called as early binding or compiler time binding. Overloading is compile time polymorphism where more than one methods share the same name with different parameters or signature and different return type.

Polymorphism (Contd.) Dynamic binding is also called as late binding or run-time binding. Dynamic polymorphism is the polymorphism that exists at run-time. Here, Java compiler does not understand which method is called at compilation time. Only JVM decides which method is called at run-time. Method overloading and method overriding using instance methods are the examples for dynamic polymorphism.