Fundamentals of Programming. By Budditha Hettige

Similar documents
Fundamentals of Programming. Budditha Hettige Department of Computer Science

Fundamentals of Programming

CHAPTER 1. Introduction to JAVA Programming

Certified Core Java Developer VS-1036

Introduction to OOP Using Java Pearson Education, Inc. All rights reserved.

Programming with Java

Java is a high-level programming language originally developed by Sun Microsystems and released in Java runs on a variety of

Lesson 04: Our First Java Program (W01D4

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

Introduction to C++ IT 1033: Fundamentals of Programming

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

Chapter 2: Programming Concepts

Wentworth Institute of Technology. Engineering & Technology WIT COMP1000. Java Basics

Chapter 3 Intro to Java

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

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

Lesson 01 Introduction

Expressions and Data Types CSC 121 Fall 2015 Howard Rosenthal

Lecture 1: Overview of Java

Expressions and Data Types CSC 121 Spring 2015 Howard Rosenthal

Getting Started with Eclipse/Java

Chapter 1 Introduction to java

Standard 11. Lesson 9. Introduction to C++( Up to Operators) 2. List any two benefits of learning C++?(Any two points)

4 Programming Fundamentals. Introduction to Programming 1 1

Introduction to Java. Java Programs Classes, Methods, and Statements Comments Strings Escape Sequences Identifiers Keywords

CS11 Java. Fall Lecture 1

Java Programming Language Mr.Rungrote Phonkam

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

BIT Java Programming. Sem 1 Session 2011/12. Chapter 2 JAVA. basic

2 rd class Department of Programming. OOP with Java Programming

3 CREATING YOUR FIRST JAVA APPLICATION (USING WINDOWS)

Università degli Studi di Bologna Facoltà di Ingegneria. Principles, Models, and Applications for Distributed Systems M

Lecture 4: Introduction to Java and your Development Environment

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

CSE 421 Course Overview and Introduction to Java

CS5000: Foundations of Programming. Mingon Kang, PhD Computer Science, Kennesaw State University

CompSci 125 Lecture 02

Outline. Parts 1 to 3 introduce and sketch out the ideas of OOP. Part 5 deals with these ideas in closer detail.

12/22/11. Java How to Program, 9/e. Help you get started with Eclipse and NetBeans integrated development environments.

Java language. Part 1. Java fundamentals. Yevhen Berkunskyi, NUoS

13 th Windsor Regional Secondary School Computer Programming Competition

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

Getting Started with Java. Atul Prakash

IT151: Introduction to Programming (java)

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

Building Java Programs. Introduction to Programming and Simple Java Programs

Getting Started With Java

C++ Spring Break Packet 11 The Java Programming Language

JAVA PROGRAMMERS GUIDE LESSON

2 Introduction to Java. Introduction to Programming 1 1

For the course, we will be using JCreator as the IDE (Integrated Development Environment).

Fundamentals of Programming Data Types & Methods

Introduction to Java. Nihar Ranjan Roy.

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

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

Full file at

COMP 110 Project 1 Programming Project Warm-Up Exercise

Outline. CIS 110: Introduction to Computer Programming. What is Computer Science? What is computer programming? What is computer science?

TUGCE KEMEROZ - ASLI OZKAN - AYSE TARTAN. Week 12/02/ /02/2007 Lecture Notes:

CS 11 java track: lecture 1

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

Basic Programming Language Syntax

1. Introduction. Java. Fall 2009 Instructor: Dr. Masoud Yaghini

Chapter 1 Introduction to Computers, Programs, and Java

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

COSC 123 Computer Creativity. Introduction to Java. Dr. Ramon Lawrence University of British Columbia Okanagan

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

Strings, Strings and characters, String class methods. JAVA Standard Edition

: Primitive data types Variables Operators if, if-else do-while, while, for. // // First Java Program. public class Hello {

AP Computer Science Summer Assignment (updated 5/29/2018) DUE : Sept. 4, 2018

Introduction to Programming (Java) 2/12

Expressions and Data Types CSC 121 Spring 2017 Howard Rosenthal

Introduction to Computers and Java

Introduction to Computers and Java. Objectives. Outline. Harald Gall, Prof. Dr. Institut für Informatik Universität Zürich.

CS212:Data Structure

Introduction to JAVA

Introduction to Computers and Java

Introduction to Computers and Java. Objectives. Outline. Harald Gall, Prof. Dr. Institut für Informatik Universität Zürich.

Introduction to Computers and Java

How to Install (then Test) the NetBeans Bundle

COMP1007 Principles of Programming

Chapter 1. Introduction

Computational Expression

Tools : The Java Compiler. The Java Interpreter. The Java Debugger

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

Introduction to Java

The Java Language Rules And Tools 3

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

COMP 2718: The OS, Shell, Terminal, and Text

Basics of Java Programming

An overview of Java, Data types and variables

1B1a Programming I Getting Started

CPS109 Lab 1. i. To become familiar with the Ryerson Computer Science laboratory environment.

Javac and Eclipse tutorial

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

Introduction to Java Applications; Input/Output and Operators

9/11/08 (c) 2008 Matthew J. Rutherford Class (c) 2008 Matthew J. Rutherford Class

Strings. Strings and their methods. Dr. Siobhán Drohan. Produced by: Department of Computing and Mathematics

Getting started with Java

Entry Point of Execution: the main Method. Elementary Programming. Learning Outcomes. Development Process

Transcription:

Fundamentals of Programming By Budditha Hettige

Overview Exercises (Previous Lesson) The JAVA Programming Languages Java Virtual Machine Characteristics What is a class? JAVA Standards JAVA Keywords How Install JAVA Sample Java Program 2

Exercises Draw a flowchart for the following 1. Enter two number from key bard and print average 2. Enter three number and find the maximum number 3. Process of the ATM machine 3

JAVA Is a programming language created by James Gosling from Sun Microsystems in 1991 Is a general-purpose, class-based, objectoriented Programming language is intended to let application developers write once, run anywhere. Current version (JDK) 7u21 URL : http://www.oracle.com/ 4

Java cont Java programming language consists Java compiler: Java compiler translates Java coding into byte-code Java virtual machine(jvm) Java virtual machine interprets this byte-code and runs the program Java class libraries Java Class Library is a set of dynamically loadable libraries that Java applications can call at run time 5

Java Virtual Machine (JVM) Architecture JAVA Source File (.java) Java Virtual Machine Java Compiler JAVA Bite code (.class) Memory Manager Java API Byte code Verifier Interpreter 6

JAVA Vs C++ JAVA Source File (.java) C++ Source File (.cpp) Java Compiler C++ Compiler JAVA Bite code (.class) Executable program (.exe) Java VM JAVA VM can directly execute Operating system can directly execute 7

Characteristics Java has the following properties Platform independent Object-orientated programming language Strongly-typed programming language Interpreted and compiled language Automatic memory management 8

Platform independent Can Run on any Platform Windows Linux MaC OS JAVA Source File (.java) Java Compiler JAVA Bite code (.class) Java VM 9

Object-orientated programming language Object-oriented programming (OOP) is a programming paradigm that represents concepts as "objects" that have data fields (State) and methods (Behavior) What is an Objects? Object is a software bundle of related state and behavior Characteristics: state and behavior Example (Person) State (Name, NIC, height) Behavior (Speech, Sleep, eat) Object is an instance of a class (instance is a specific realization of any object) 10

What is a class? A Java class is a group of Java methods and variables Example (Person) State (Name, NIC, height) Behavior (Speech, Sleep, eat) class Person { } 11

Requirements for Class name Class name must begin with letter of the alphabet Contains only letters, digits, underscores or dollar sign Cannot be a language reserved keywords (public, class etc) Name cannot be following values (true, false or null) 12

Java Class name standard Begin with uppercase letter No spaces Emphasizes new word with an initial uppercase letter Example EmployeRecords Student FirstExample SampleProgram 13

Java Keywords 14

Install JAVA Download Java Development Kit (JDK) http://www.oracle.com RUN Installation setup SET PATH for the JAVA Test JAVA is working Video Link http://www.dscs.sjp.ac.lk/~budditha/java/vd/ins/install.html 15

Simple Java Program A class with a main Method public class FirstProgram { public static void main(string[] args) { System.out.println("Hello"); } } FirstProgram Operating System Output Main Method 16

A class without a main Method public class FirstProgram { } Operating System Can not Execute the program FirstProgram Operating System 17

Your first Java program Open a text editor (text pad, Notepad etc.) Type the following sample Save program as FirstProgram.java public class FirstProgram { public static void main(string[] args) { System.out.println("Hello World"); } } 18

Compile and RUN Using command prompt go to the place where in your java file To Compile: type javac <space><filename> Javac FirstProgram.java To Run: type java<space><filename> Java FirstProgram Video Link http://www.dscs.sjp.ac.lk/~budditha/java/vd/s1/02.html 19

First Java program public class FirstProgram { public static void main(string[] args) { System.out.println("Hello World"); } } Flow chart Start Display Hello World End 20

Print Output on Command window Function System.out.println( Some Text ); System.out.print( Some Text ); Example public class FirstProgram { public static void main(string[] args) { System.out.println("Hello World"); } } 21

Escape Sequences A character preceded by a backslash (\) is an escape sequence has special meaning to the compiler Escape Sequence Description \t Insert a tab in the text at this point. \b Insert a backspace in the text at this point. \n Insert a newline in the text at this point. \r Insert a carriage return in the text at this point. \f Insert a formfeed in the text at this point. \' Insert a single quote character in the text at this point. \" Insert a double quote character in the text at this point. \\ Insert a backslash character in the text at this point. 22

ASCII art with JAVA ASCII art is a graphic design technique that uses computers for presentation and consists of pictures pieced together from the 95 printable (from a total of 128) characters defined by the ASCII Standard from System.out.println(" @ @ @ "); System.out.println(" @ @ @ @ "); System.out.println(" @ @ @ "); System.out.println(" \\ / "); System.out.println(" "); System.out.println(" "); System.out.println(" "); System.out.println(" "); System.out.println(" ( ) "); System.out.println(" ^^^^^ "); 23

Exercise 1. Why JAVA is Platform independent? 2. What class? 3. What is JAVA Runtime Environment (JRE)? 4. What is JAVA Class file? 5. Write a JAVA Program to Display the Following output ------------------------------- HSIT 2130 Fundamentals of Programming ------------------------------- 6. Try to run the above program on the Linux machine 24