Sri Lanka News

Topics: Java, Programming language, Python Pages: 7 (897 words) Published: August 5, 2013
HSIT 2130
Fundamentals of Programming

By Budditha Hettige
Department of Statistics and Computer Science

• • • • • • • • • 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

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


• 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 :


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 Byte code Verifier Memory Manager JAVA Bite code (.class)

Java Compiler


Java API


JAVA Source File (.java)

C++ Source File (.cpp)

Java Compiler

C++ Compiler

JAVA Bite code (.class)

Executable program (.exe) Operating system can directly execute

Java VM

JAVA VM can directly execute


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


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)

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 { }

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


Install JAVA
• Download Java Development Kit (JDK)

• • • •

RUN Installation setup SET PATH for the JAVA Test JAVA is working Video Link –


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


Main Method 16

A class without a main Method
public class FirstProgram { }

Operating System Can not Execute the program

FirstProgram Operating System


Your first Java program
• Open a text editor (text pad, Notepad etc.) • Type the following sample • Save program as “” public class FirstProgram { public static void main(String[] args) {...
Continue Reading

Please join StudyMode to read the full document

You May Also Find These Documents Helpful

  • Sri Lanka Tourism Essay
  • Development Constraints in Sri Lanka Essay
  • Tourism Industry of Sri Lanka Essay
  • Vending Machine Sri Lanka Essay
  • Fab India in Sri Lanka Essay
  • Traditional Dancing in Sri Lanka Essay
  • Augmented Reality in Sri Lanka Essay
  • An Architect of Sri Lanka- Geoffrey Bawa Essay

Become a StudyMode Member

Sign Up - It's Free