Lesson 01 Introduction

Similar documents
Introduction. Lecture 1 MIT 12043, Fundamentals of Programming By: S. Sabraz Nawaz

Lecture 1: Introduction to Java

Chapter 1 Introduction to Computers, Programs, and Java

Java Language. Programs. Computer programs, known as software, are instructions to the computer. You tell a computer what to do through programs.

Introduction. Introduction to OOP with Java. Lecture 01: Introduction to OOP with Java - AKF Sep AbuKhleiF -

Introduction to OOP with Java. Instructor: AbuKhleif, Mohammad Noor Sep 2017

Introduction to Java. Liang, Introduction to Java Programming, Ninth Edition, (c) 2013 Pearson Education, Inc. All rights reserved.

Chapter 1 Introduction to Computers, Programs, and Java. What is a Computer? A Bit of History

Getting Started. Chapter 1. Java Programming FROM THE BEGINNING. Chapter 1: Getting Started

Chapter 1 Introduction to Computers, Programs, and Java

Chapter 1 Introduction to Computers, Programs, and Java

Chapter 1 Introduction to Computers, Programs, and Java

Objectives. Chapter 1 Introduction to Computers, Programs, and Java. What is a Computer?

3 CREATING YOUR FIRST JAVA APPLICATION (USING WINDOWS)

CHAPTER 1 Introduction to Computers and Java

Programming: detailed instructions which tell the computer hardware what to do aka software Computer Science: the study NOT of computers, but of what

Chapter 1: Introduction to Computers, Programs, and Java

Module 1: Introduction to Computers, Programs, and Java

Chapter 1: Introduction to Computers and Java

8/23/2014. Chapter Topics. Introduction. Java History. Why Program? Java Applications and Applets. Chapter 1: Introduction to Computers and Java

Chapter 1 Introduction to Computers, Programs, and Java

Getting Started with Java. Atul Prakash

CHAPTER 1. Introduction to JAVA Programming

Chapter 1 Introduction to Computers, Programs, and Java

Elements of Computers and Programming Dr. William C. Bulko. What is a Computer?

Lesson 02 Data Types and Statements. MIT 11053, Fundamentals of Programming By: S. Sabraz Nawaz Senior Lecturer in MIT Department of MIT FMC, SEUSL

Introduction to Computers, Programs, and Java. CSE 114, Computer Science 1 Stony Brook University

Fundamentals of Programming. By Budditha Hettige

Lecture 2. COMP1406/1006 (the Java course) Fall M. Jason Hinek Carleton University

Lecture 1 - Introduction (Class Notes)

Chapter 1 Introduction to Computers, Programs, and Java

Decision Structures. Lesson 03 MIT 11053, Fundamentals of Programming

Chapter 1 Introduction to Computers, Programs, and Java

Tutorial 1 CSC 201. Java Programming Concepts عؾادئماظربجمةمبادؿكدامماجلاصا

COT 3530: Data Structures. Giri Narasimhan. ECS 389; Phone: x3748

Lesson 02 Data Types and Statements. MIT 12043, Fundamentals of Programming By: S. Sabraz Nawaz Senior Lecturer in MIT Department of MIT FMC, SEUSL

Java Programming Language Mr.Rungrote Phonkam

CompSci 125 Lecture 02

Certified Core Java Developer VS-1036

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

Goals. Java - An Introduction. Java is Compiled and Interpreted. Architecture Neutral & Portable. Compiled Languages. Introduction to Java

Introduction to Java Programming

COMP-202: Foundations of Programming. Lecture 2: Java basics and our first Java program! Jackie Cheung, Winter 2016

Introduction to Java. Lecture 1 COP 3252 Summer May 16, 2017

Introduction to Java. Nihar Ranjan Roy.

Assoc. Prof. Dr. Marenglen Biba. (C) 2010 Pearson Education, Inc. All rights reserved.

Outline. Introduction to Java. What Is Java? History. Java 2 Platform. Java 2 Platform Standard Edition. Introduction Java 2 Platform

Introduction Basic elements of Java

Programming with Java

CSE 1223: Introduction to Computer Programming in Java Chapter 1 Computer Basics

MIT Database Management Systems Lesson 03: Entity Relationship Diagrams

Lesson 04: Our First Java Program (W01D4

Programming. Syntax and Semantics

COMP6700/2140 JDK Tools

Life Without NetBeans

Eng. Mohammed S. Abdualal

CHAPTER 1 INTRODUCTION TO COMPUTERS, PROGRAMS, AND JAVA. Objectives

CT 229. CT229 Lecture Notes. Labs. Tutorials. Lecture Notes. Programming II CT229. Objectives for CT229. IT Department NUI Galway

1. Java is the fastest growing programming language in the world.

Creating a Program in JCreator. JCreator is then used to create our program. But the first step is to create a new file.

From Algorithms to Architecture....a lightning introduction to computer architecture

Index. Course Outline. Grading Policy. Lab Time Distribution. Important Instructions

Getting Started With Java

At its simplest, a computer is a collection of wires, transistors and electrical components that are connected in a specific way When you send

COMP-202: Foundations of Programming. Lecture 2: Java basics and our first Java program! Jackie Cheung, Winter 2015

Building Java Programs. Introduction to Programming and Simple Java Programs

Lecture 1: Overview of Java

Computer Components. Software{ User Programs. Operating System. Hardware

Networks Programming Engr. Abdul-Rahman Mahmood MS, PMP, MCP, QMR(ISO9001:2000)

13 th Windsor Regional Secondary School Computer Programming Competition

Learning objectives. The Java Environment. Java timeline (cont d) Java timeline. Understand the basic features of Java

The Computer System. Hardware = Physical Computer. Software = Computer Programs. People = End Users & Programmers. people

Programming in Java Prof. Debasis Samanta Department of Computer Science Engineering Indian Institute of Technology, Kharagpur

Week 2: Data and Output

SKILL AREA 304: Review Programming Language Concept. Computer Programming (YPG)

Chapter 1 Introduction to Java

AP Computer Science A: Java Programming

Chapter 1. Introduction to Computers and Java Objects. Background information. » important regardless of programming language. Introduction to Java

A Set Of Machine Language Instructions For A Program Is Called Source Code >>>CLICK HERE<<<

2/9/2012. Chapter One: Introduction. Chapter Goals

CS 177 Recitation. Week 1 Intro to Java

Lec 3. Compilers, Debugging, Hello World, and Variables

II. Compiling and launching from Command-Line, IDE A simple JAVA program

CSE 421 Course Overview and Introduction to Java

JVM interprets the Java bytecode, controls how it interacts with the operating system and manages memory.

Chapter 1. Introduction

Javac and Eclipse tutorial

History of Java. Java was originally developed by Sun Microsystems star:ng in This language was ini:ally called Oak Renamed Java in 1995

TTh 9.25 AM AM Strain 322

CS 11 java track: lecture 1

ICOM 4015: Advanced Programming

Class List. Java Must Have. Class Goals. Class Goals. Schedule

CSC116: Introduction to Computing - Java

CS 231 Data Structures and Algorithms, Fall 2016

INDEX. A SIMPLE JAVA PROGRAM Class Declaration The Main Line. The Line Contains Three Keywords The Output Line

Introduction to Programming with Java

An Introduction to Software Engineering. David Greenstein Monta Vista High School

CSc 2010 Principles of Computer Science, Fall 2013 Practice Problems for Midterm 3* * 3 17 % 9-20 % (26 / 7) "2"

2 Getting Started. Getting Started (v1.8.6) 3/5/2007

AP Computer Science A

Transcription:

Lesson 01 Introduction MIT 12043, Fundamentals of Programming By: S. Sabraz Nawaz Lecturer in Management & IT M.Sc. In IS (SLIIT), PGD in IS (SLIIT), BBA (Hons.) Spl. in IS (SEUSL), MCP

Programs Computer programs, known as software, are instructions to the computer. You tell a computer what to do through programs. Without programs, a computer is an empty machine. Computers do not understand human languages, so you need to use computer languages to communicate with them. Programs are written using programming languages. MIT 12043 by S.Sabraz Nawaz 2

Programming Languages Machine Language Assembly Language High-Level Language Machine language is a set of primitive instructions built into every computer. The instructions are in the form of binary code, so you have to enter binary codes for various instructions. Programming with native machine language is a boring process. Moreover the programs are highly difficult to read and modify. For example, to add two numbers, you might write an instruction in binary like this: 1101101010011010 MIT 12043 by S.Sabraz Nawaz 3

Programming Languages Machine Language Assembly Language High-Level Language Assembly languages were developed to make programming easy. Since the computer cannot understand assembly language, however, a program called assembler is used to convert assembly language programs into machine code. For example, to add two numbers, you might write an instruction in assembly code like this: ADDF3 R1, R2, R3 MIT 12043 by S.Sabraz Nawaz 4

Programming Languages Machine Language Assembly Language High-Level Language The high-level languages are English-like and easy to learn and program. For example, the following is a high-level language statement that computes the area of a circle with radius 5: area = 5 * 5 * 3.1415; MIT 12043 by S.Sabraz Nawaz 5

Popular High-Level Languages COBOL (COmmon Business Oriented Language) FORTRAN (FORmula TRANslation) BASIC (Beginner All-purpose Symbolic Instructional Code) Pascal (named for Blaise Pascal) Ada (named for Ada Lovelace) C (whose developer designed B first) Visual Basic (Basic-like visual language developed by Microsoft) Delphi (Pascal-like visual language developed by Borland) C++ (an object-oriented language, based on C) C# (a Java-like language developed by Microsoft) Java MIT 12043 by S.Sabraz Nawaz 6

How a Computer Program Works The Program you write is executed by the CPU Since the CPU can only understand machine code your program needs to be converted into machine code MIT 12043 by S.Sabraz Nawaz 7

How a Computer Program Works Dim radius as integer Dim area as integer radius = txtradius.text area = 22/7*radius*radius msgbox area Source Code C8 B7 23A7 D7 AA 89 DD 89D23 A9 F4 A9... Machine Code MIT 12043 by S.Sabraz Nawaz 8

How a Computer Program Works Programmer writes the code in a high level language such as C++, Java, Visual Basic etc. Then using a software tool this high level code is converted into machine code The software tools that does the conversion to machine code comes in two flavours o Compilers o Interpreters MIT 12043 by S.Sabraz Nawaz 9

Compiling Source Code A program written in a high-level language is called a source program. Since a computer cannot understand a source program. Program called a compiler is used to translate the source program into a machine language program called an object program. The object program is often then linked with other supporting library code before the object can be executed on the machine. MIT 12043 by S.Sabraz Nawaz 10

Compilers and Interpreters Compiler o A compiler converts your entire program to machine code at one go o After compilation you have an executable file in machine code e.g. an EXE, COM file for PCs Interpreter o An Interpreter converts your program to machine code one instruction at a time MIT 12043 by S.Sabraz Nawaz 11

Developing Programs that run on Multiple Platforms You need to find a language that is supported by different platforms e.g. Visual Basic is only for PCs, C, C++ on the other hand are available for any type of computer MIT 12043 by S.Sabraz Nawaz 12

Developing Programs that run on Multiple Platforms We say that languages like C, C++ are portable at the source level o i.e. Since these languages have standards the program you write (source code) could be compiled on different platforms with little or no modifications MIT 12043 by S.Sabraz Nawaz 13

What makes Java Special? Java is platform independent at the binary level o i.e. If you write a program in Java and compile it you could run your compiled code on any type of computer When you compile a java program it does not produce machine code for a specific type of computer MIT 12043 by S.Sabraz Nawaz 14

How Java works? It instead creates machine code for a general virtual computer o This is referred to as java byte code o There are Java Interpreters available for almost all types of computer platforms To run your Java program you need the Java Interpreter installed in that computer It would convert the java byte code to the specific machine code of your computer MIT 12043 by S.Sabraz Nawaz 15

How Java works? MIT 12043 by S.Sabraz Nawaz 16

Program Development Process Text editor Saves Java statements Source code (.java) Java compiler Produces Byte code (.class) Java Virtual Machine Results in Program Execution MIT 12043 by S.Sabraz Nawaz 17

A Simple Java Program MIT 12043 by S.Sabraz Nawaz 18

Creating, Compiling, and Executing a Java Program MIT 12043 by S.Sabraz Nawaz 19

The Compiler and the Java Virtual Machine Most compilers translate source code into executable files containing machine code The Java compiler translates a Java source file into a file that contains byte code instructions Byte code instructions are the machine language of the Java Virtual Machine (JVM) and cannot be directly executed directly by the CPU MIT 12043 by S.Sabraz Nawaz 20

The Compiler and the Java Virtual Machine Byte code files end with the.class file extension The JVM is a program that emulates a micro-processor The JVM executes instructions as they are read JVM is often called an interpreter Java is often referred to as an interpreted language. MIT 12043 by S.Sabraz Nawaz 21

Java Virtual Machine The Java Interpreter is more popularly known as the Java Virtual Machine (JVM). It is also known as the Java Runtime This is available with the operating system of most computers today MIT 12043 by S.Sabraz Nawaz 22

Java Virtual Machine (a) Java source code is translated into bytecode. (b) Java bytecode can be executed on any computer with a Java Virtual Machine. MIT 12043 by S.Sabraz Nawaz 23

Sample Program MIT 12043 by S.Sabraz Nawaz 24

PRACTICAL WORK Example done for you

We use Java SE 7, Sun s latest version of Java language Basic types of Java programs. Java console applications Java GUI applications Java applets

Requirements.. In order to write a Java program we need: o o o An editor A Java compiler A Java Runtime Environment/Java Platform Editor Notepad, WordPad, etc. Java Compiler and Platform Sun s Java Development Kit

Java Development Kit This is a software package designed to help with the complete process of developing and running Java programs. It combine the functions of Compiler Interpreter Applet viewer Debugger

Example 1 Write a program to print, Hello, Welcome to MIT 12043 This program demonstrates how to write a simple java program.

Exercise 1 class Hello { public static void main(string[] args) { System.out.println("Hello, Welcome to MIT 12043"); } }

Example 1 class Hello { public static void main(string[] args) { System.out.println(" Hello, Welcome to MIT 12043 "); } } Name of Class

Example 1 class Hello { public static void main(string[] args) { System.out.println(" Hello, Welcome to MIT 12043 "); } } { - begin } - end

Example 1 class Hello { public static void main(string[] args) { System.out.println(" Hello, Welcome to MIT 12043 "); } } Main method (function). Java will perform the commands under this method.

Example 1 class Hello { public static void main(string[] args) { System.out.println(" Hello, Welcome to MIT 12043 "); } } Semi Colon ; indicates end of a command

Example 1 class Hello { } public static void main(string[] args) { System.out.println(" Hello, Welcome to MIT 12043 "); } Print Command in Java What ever in quotations will be printed as it is. i.e. Hello, Welcome to JAVA

Example 1 class Hello { public static void main(string[] args) { System.out.println(" Hello, Welcome to MIT 12043 "); } } Java like C and C++ is case sensitive i.e. if you type the first part of the as Public static void.. Your program will not work

Example 1 class Hello { public static void main(string[] args) { System.out.println(" Hello, Welcome to MIT 12043 "); } }

Compiling a Java Program To Compile your Java Program use the JDK s javac tool. E:\myjava>javac Hello.java The compiler would create java byte code. These files have an extension of.class

Running a Java Program To run your Java Programs you need to call the Java Interpreter. E:\myjava>java Hello

Example 2 Write a program that produces the following output Hello World! It's been nice knowing you. Goodbye world!

Example 2 - Solution 2 class HelloWorld { public static void main (String args[]) { System.out.println("Hello World!"); System.out.println("It's been nice knowing you."); System.out.println("Goodbye world!"); } }

Example 2 - Solution 2 class HelloWorld { } public static void main (String args[]) { } System.out.println("Hello World!\nIt's been nice knowing you.\ngoodbye world!"); \n is for new line

Exercise 1 Write a Java program using one println() statement to print your name and age on the screen. Your program should format the output as follows. Hello! I am SaNa. I am 36 years old.

Try these out Ex 01 MIT 12043 by S.Sabraz Nawaz 44

class DrawPicture { public static void main (String args[]) { System.out.println("* * * * * * "); System.out.println("* * * * * * * "); System.out.println("* * * * * * * *"); System.out.println("* * * * * * * * * *"); } }

MIT 12043 by S.Sabraz Nawaz 46

End of Lecture