itft-overview of java language

14
OVERVIEW OF LANGUAGE

Upload: atul-sehdev

Post on 19-May-2015

120 views

Category:

Education


2 download

DESCRIPTION

Introduction, Simple Java Program, More of Java, An application With Two classes

TRANSCRIPT

Page 1: itft-Overview of java language

OVERVIEW OF

LANGUAGE

Page 2: itft-Overview of java language

Contents

• Introduction

• Simple Java Program

• More of Java

• An application With Two classes

Page 3: itft-Overview of java language

Introduction

• JAVA is a general purpose object oriented language.

• We can develop two types of JAVA programs:-

• Stand-alone Application:- these are java programs that are used to carry out a certain task at a stand- alone local computer.

• Web Applets:- Web applets are the small java programs used to develop web applications.

Page 4: itft-Overview of java language

Introduction continue..

• Executing a Stand- alone application involve two

steps

• Compile the source code into byte code(javac compiler).

• Executing the byte code program(java interpreter).

• Executing a Web Applets also involve two steps

• Compile the source code into byte code(javac compiler).

• Executing the byte code with java enabled browser.

Page 5: itft-Overview of java language

Simple Java Program

• Let us look at a simple code that would print the words Hello World.

public class MyFirstJavaProgram

{

/* This is my first java program.

This will print 'Hello World' as the output */

public static void main(String []args)

{

System.out.println("Hello World");//prints Hello World

}

}

Page 6: itft-Overview of java language

Simple Java Program

• Let us look at a simple code that would print the words Hello World.

public class MyFirstJavaProgram Class Declaration

{

/* This is my first java program.

This will print 'Hello World' as the output */

public static void main(String []args)

{

System.out.println("Hello World");//prints Hello World

}

}

Page 7: itft-Overview of java language

Simple Java Program

• Let us look at a simple code that would print the words Hello World.

public class MyFirstJavaProgram Class Declaration

{ Opening Brace

/* This is my first java program.

This will print 'Hello World' as the output */

public static void main(String []args)

{

System.out.println("HelloWorld");//prints HelloWorld

}

}

Page 8: itft-Overview of java language

Simple Java Program

• Let us look at a simple code that would print the words Hello World.

public class MyFirstJavaProgram Class Declaration

{ Opening Brace

/* This is my first java program.

This will print 'Hello World' as the output */

public static void main(String []args) the main line

{

System.out.println("HelloWorld");//prints HelloWorld

}

}

Page 9: itft-Overview of java language

Simple Java Program

• Let us look at a simple code that would print the words Hello World.

public class MyFirstJavaProgram Class Declaration

{ Opening Brace

/* This is my first java program.

This will print 'Hello World' as the output */

public static void main(String []args) the main line

{

System.out.println("HelloWorld");//prints HelloWorld output line

}

}

Page 10: itft-Overview of java language

More of java

import java.lang.Math;

public class Exercise

{

public static void main(String[] args)

{

double x = 16;

double y;

y= Math.sqrt(x);

System.out.println("The square root of " +y);

}

}

Page 11: itft-Overview of java language

More of java

import java.lang.Math;

public class Exercise

{

public static void main(String[] args)

{

double x = 16;

double y;

y= Math.sqrt(x); math function

System.out.println("The square root of " +y);

}

}

Page 12: itft-Overview of java language

An application With Two classesclass Room{

float length;float breadth;void getdata(float a, float b){

length= a;breadth= b;

}}

Page 13: itft-Overview of java language

Continue..

class RoomArea

{

public static void main(String args[])

{

float area;

Room room1= new Room (); //creates an object room1

room1.getdata(14,10);//assign value to length and breadth

area = room1.length * room1.breadth;

System.out.println(“Area =”+area);

}

}

Page 14: itft-Overview of java language