1.history of Java

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 4

History of Java

Java is platform of independent software language. Earlier the language was name OAK. Earlier it was made for internal
use of some OAK name of tree (coffee).Java is made of Java Bin. Java is complete object oriented programming language.
Java can be used on the internet were C++ now.
{* In 1960’s internet is developed}
{ *Applet-Applet can be used only Net}
Features of Java
1. Java is a complete OOP’s language.
2. Java provides all the features of an OOP language i.e. Encapsulation, Polymorphism & Inheritance.
3. Java provides higher level of security.
4. Java uses familiar codes.
5. Java provides the concept of reusability, one class function use more than one times.
6. Java is platform independent language.
Explanation of Java
Everything will be part of Java .Java uses same code like C++.
Embedded technology
Programming is done at cheap level. Java is used an internet embedded technology & standard form so it is a
robust language.
Byte code
After compilation in java source code converted into byte code, byte code can be represented as dot class file. Dot
class file contains byte code. The source code must be save using Java.
Compiler
javac filename .java
Run –
JRE + Interpreter =JVM
{JRE-Java runtime Environment}
{JVM-Java virtual machine}
NOTE:-
OS is also known as JVM.
Byte code also runs in JVM. It can’t run any operating system.
JVM makes, java platform independent.
Some points:-
I. After compilation only machine code obtained.
II. Source code compiled byte code.
III. Byte code runs necessary JVM.
IV. Java doesn’t have on Id usually work on DOS.
V. JIT (Just Intype compiler) which convert machine code.
VI. Java is case sensitive.
Program
public class Test
{
public static void main(String[] args)
{
System.out.print("Hellow world");
}
}Note:-
1. Name of class – (e.g.-Test) & filename must be same.
2. In C++ we use public, private & protected but Java basically used public.
3. (a)static = access without object .
(b) main existence without object.
4. Void- No return.
5. Main – Identify program.
6. Main (String arg[])- It is a member function.
7. String is a class in Java these classes used as data type to stop. String is definite not another.
8. arg[] = arg is a variable write any name.
9. System = again one class in which first letter is capital.
10. Class have not existence but object have existence feature defined under the class.
Predefined class-
It must start capital but one or more than word then first letter capital.
E.g.- ArrayIndexOutOfBoundsException.
All the predefined method or predefined class has one or more word first word small & method second word
first letter capital.
E.g.- toUpperCase()
Data type-
1. byte
2. boolean 1 byte
3. char
4. short 2 byte
5. int
6. float 4 byte
7. long
8. double 8 byte

Java represents Unicode not ASCII character like Roman, Arabic character that means different languages used in
character.
Boolean-
Boolean used two values either true or false, not but in double quotes, then convert in string or character. No any
quotes used & write in small character.
Short-
Integer value reduces half no space wastage so use short.
Long –
Integer value just doubles value change.
Double-
Integer capacity is just double.

Unique constant called literal in Java :-


Boolean/ Boolean literals-
It will take two vales true (1) or false (0).
Character literals-
It is uses by single quotes. Example –’A’
Integer literals-
Will take any numeric +ve or –ve value.
Example- +12,-12
Float literals-
The number must be suffix F/f.
If not use F then value will be treated as double not float. Without float any floating value is double.
String literal-
It is represented by using double quotes. Example-”ABC”.
Note:-
Java doesn’t support implicit typecasting.
Typecasting-
Conversion from one type to another called typecasting.
Implicit typecasting-
Which is done by the system. Java doesn’t support implicit typecasting.
Explicit typecasting-
Which is done by the user. It does support by Java.
float x=12.25
1. Error obtains in java because we not use float f. It is a implicit typecasting which is not supported by Java.
2. In some cases Java also support implicit typecasting but it depends on certain condition.
a. It is the prime requirement of the system.
b. It must be form the lower type to higher type, means float to double possible but not possible double to float. So
be preferred explicit typecasting.
Example- random()
(Math.random ( )*100)
Explicit typecasting
Program:-
1. WAP in Java addition of two numbers.
class Add
{

public static void main(String arg[])


{
int a=10,b=20,c;
c= a + b;
System.out.println("Sum="+c);
}
}
2. WAP to convert a Temperature ⁰C to ⁰F.
class Degree
{
float C , F=0 ;
public void Display(float i)
{
C=i;
F=(9*C)/5+32;
System.out.println(F);
}
public static void main(String arg[])
{
Degree dd=new Degree();
float k=Float.parseFloat(arg[0]);
dd.Display(k);
}
}

3. WAP to find out simple interest where P, R & T are given.


class SimpleInterest
{
public static void main(String args[])
{
int P=1000,R=10,T=5,SI ;
SI= (P*R*T)/100;
System.out.println(SI);
}
}
4. WAP to reverse four digit numbers using loop.

class Reverse
{
int rev=0,rem,num;
public void display(int i)
{
num=i;
while(num!=0)
{
rem=num%10;
rev=rev*10+rem;
num=num/10;
}
System.out.println("the reverse of the number is="+rev);
}
public static void main(String arg[])
{
Reverse rr=new Reverse();
int j=Integer.parseInt(arg[0]);
rr.display(j);
}
}

You might also like