KEMBAR78
itft-Overview of java language | PDF
OVERVIEW OF
LANGUAGE
Contents
• Introduction
• Simple Java Program
• More of Java
• An application With Two classes
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.
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.
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
}
}
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
}
}
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
}
}
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
}
}
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
}
}
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);
}
}
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);
}
}
An application With Two
classes
class Room
{
float length;
float breadth;
void getdata(float a, float b)
{
length= a;
breadth= b;
}
}
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);
}
}
itft-Overview of java language

itft-Overview of java language

  • 1.
  • 2.
    Contents • Introduction • SimpleJava Program • More of Java • An application With Two classes
  • 3.
    Introduction • JAVA isa 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.
  • 4.
    Introduction continue.. • Executinga 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.
  • 5.
    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 } }
  • 6.
    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 } }
  • 7.
    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 } }
  • 8.
    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 } }
  • 9.
    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 } }
  • 10.
    More of java importjava.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); } }
  • 11.
    More of java importjava.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); } }
  • 12.
    An application WithTwo classes class Room { float length; float breadth; void getdata(float a, float b) { length= a; breadth= b; } }
  • 13.
    Continue.. class RoomArea { public staticvoid 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); } }