SlideShare ist ein Scribd-Unternehmen logo
1 von 19
Downloaden Sie, um offline zu lesen
Mukesh kumar C.S.E.
1110751908 5th
Semester
INTRODUCTION TO JAVA
Java language was developed by Sun Microsystem in the year 1991 as a part of green project.
GREEN PROJECT:
a research group was working to develop software to control consumer electronics devices, during
this time they developed a device called " star 7"
for which the operating system was planned to be developed in "c++"
however one of the team member "James Gosling " was not very satisfy with the performance of
c++ hence he developed a new language for start he named it as "oak"
.he used to see an oak outside his office
in 1995 Sun Microsystem renamed this language as java.
FEATURES OF JAVA:
1) Object Oriented Programming
2) Platform Independent
3) Robust
4) Reliable, Safe & Secure
5) Compiler and Interpreter
6) Dynamic
7) Multithreaded
8) High perfomance
9) Portable
10) Simple & Easy to learn
Mukesh kumar C.S.E.
1110751908 5th
Semester
Object Oriented
o Object oriented throughout - no coding outside of class definitions, including
main().
o An extensive class library available in the core language packages.
Platform Independence
o The Write-Once-Run-Anywhere ideal has not been achieved (tuning for different
platforms usually required), but closer than with other languages.
Robust
o Exception handling built-in, strong type checking (that is, all data must be declared
an explicit type), local variables must be initialized.
Security
o No memory pointers
o Programs runs inside the virtual machine sandbox.
o Array index limit checking
security manager - determines what resources a class can access such as reading and
writing to the local disk
Compiler/Interpreter
o Code is compiled to bytecodes that are interpreted by a Java virtual machines (JVM)
.
o This provides portability to any machine for which a virtual machine has been
written.
o The two steps of compilation and interpretation allow for extensive code checking
and improved security.
Dynamic Binding
o The linking of data and methods to where they are located, is done at run-time.
o New classes can be loaded while a program is running. Linking is done on the fly.
o Even if libraries are recompiled, there is no need to recompile code that uses classes
in those libraries.
This differs from C++, which uses static binding. This can result in fragile classes for
cases where linked code is changed and memory pointers then point to the wrong
addresses.
Mukesh kumar C.S.E.
1110751908 5th
Semester
High Performance
o Interpretation of bytecode slowed performance in early versions, but advanced
virtual machines with adaptive and just-in-time compilation and other techniques
now typically provide performance up to 50% to 100% the speed of C++ programs.
Threading
o Lightweight processes, called threads, can easily be spun off to perform
multiprocessing.
o Can take advantage of multiprocessors where available
o Great for multimedia displays.
What is the Java Virtual Machine?
The JVM is the software that executes Java bytecode. A Java program, written in a file with a
.java extension, is compiled into class files that have a .class extension. The class files are
written in bytecode. To execute these files, the computer uses the JVM to interpret the
bytecode.
A browser that is capable of executing Java applets has the JVM built into it. To run a Java
application, the Java Runtime Environment (JRE) must be installed. The JRE contains the
files in the Java Development Kit minus the development tools, only the files necessary to
run a Java application are present.
The bytecode is the same for all platforms, but the JVM will be different on different
platforms because it needs to execute programs using the native code of the machine it is
running on.
Development Tools: The development tools provide everything you'll need for compiling, running,
monitoring, debugging, and documenting your applications. As a new developer, the main tools
you'll be using are the javac compiler, the java launcher, and the javadoc documentation tool.
What is an Object
Object is instance of class, it contain data as well as behavior of the functions how to manipulate
that data.
What is a Class
Class is a collection of similar objects.
A class is a blueprint or prototype from which objects are created.
Mukesh kumar C.S.E.
1110751908 5th
Semester
EXPERIMENT NO.1
Aim:-- Write a program to display welcome note.
class W
{
public static void main(String args[])
{
System .out.println("welcome");
}
}
Mukesh kumar C.S.E.
1110751908 5th
Semester
Output:--
Mukesh kumar C.S.E.
1110751908 5th
Semester
EXPERIMENT NO.2
Aim:-- Write a program to compute the circle of area.
class mkk
{
public static void main(String args[])
{
int r;
r = 5;
float pi = 3.14f;
System.out.println(pi * r * r);
}
}
Mukesh kumar C.S.E.
1110751908 5th
Semester
Output:--
Mukesh kumar C.S.E.
1110751908 5th
Semester
EXPERIMENT NO.3
Aim:-- Write a program add two number using command line argument .
class mss
{
public static void main(String args[])
{
int a,b,c;
a=Integer.parseInt(args[0]);
b=Integer.parseInt(args[1]);
c=a+b;
System.out.println("addition="+c);
}
}
Mukesh kumar C.S.E.
1110751908 5th
Semester
Output:--
Mukesh kumar C.S.E.
1110751908 5th
Semester
EXPERIMENT NO.4
Aim:-- Write a program to display menu 1(Addition), 2(subtraction), 3(Multiplication),
4(Division).
class mss
{
public static void main(String args[])
{
int a,b,c,d;
a=Integer.parseInt(args[0]);
b=Integer.parseInt(args[1]);
c=Integer.parseInt(args[2]);
switch(a)
{
case 1:
{
d=b+c;
System.out.println("addition="+d);
break;
}
case 2:
{
d=b-c;
System.out.println("substraction="+d);
break;
}
case 3:
{
d=b*c;
System.out.println("multiplication="+d);
break;
}
case 4:
{
d=b/c;
System.out.println("division="+d);
break;
}
default:
{
System.out.println("invalid");
}
}
}
}
Mukesh kumar C.S.E.
1110751908 5th
Semester
Output:--
Mukesh kumar C.S.E.
1110751908 5th
Semester
EXPERIMENT NO.5
Aim:-- Write a program to print all the odd number 1 to 50.
class P
{
public static void main(String args[] )
{
for(int i=1;i<=50;i=i+2)
{
System.out.println(i);
}
}
}
Mukesh kumar C.S.E.
1110751908 5th
Semester
Output:--
Mukesh kumar C.S.E.
1110751908 5th
Semester
EXPERIMENT NO.6
Aim:-- Write a program to find wheather the number is prime or not.
class mk
{
public static void main(String args[])
{
int i;
int no=Integer.parseInt(args[0]);
for(i=2;i<=no;i++)
{
if(no % i==0)
break;
}
if(no==i)
{
System.out.println("prime number");
}
else
{
System.out.println("not prime number");
}
}
}
Mukesh kumar C.S.E.
1110751908 5th
Semester
Output:--
Mukesh kumar C.S.E.
1110751908 5th
Semester
EXPERIMENT NO.7
Aim:-- Write a program to show fibonsci series from 1 to 21.
class ms
{
public static void main(String args[])
{
int a=1,b=0,t;
for(int i=1;i<=21;i++)
{
System.out.println(a);
t=a+b;
b=a;
a=t;
}
}
}
Mukesh kumar C.S.E.
1110751908 5th
Semester
Output:--
Mukesh kumar C.S.E.
1110751908 5th
Semester
EXPERIMENT NO.8
Aim:-- Write a program print sum and average of 5 number in single array .
class array
{
public static void main(String args[])
{
int a []=new int[5],i,s=0,h=0;
for(i=0;i<=4;i++)
a[i]=Integer.parseInt(args[i]);
for(i=0;i<=4;i++)
{
s=s+a[i];
}
System .out.println("sum is"+s);
h=s/5;
System .out.println("ave is"+h);
}
}
Mukesh kumar C.S.E.
1110751908 5th
Semester
Output:--

Weitere ähnliche Inhalte

Was ist angesagt?

Introduction to Java Programming Language
Introduction to Java Programming LanguageIntroduction to Java Programming Language
Introduction to Java Programming Languagejaimefrozr
 
String and string buffer
String and string bufferString and string buffer
String and string bufferkamal kotecha
 
Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)Animesh Chaturvedi
 
Constructor in java
Constructor in javaConstructor in java
Constructor in javaHitesh Kumar
 
2CPP14 - Abstraction
2CPP14 - Abstraction2CPP14 - Abstraction
2CPP14 - AbstractionMichael Heron
 
Python Dictionaries and Sets
Python Dictionaries and SetsPython Dictionaries and Sets
Python Dictionaries and SetsNicole Ryan
 
Introduction to basics of java
Introduction to basics of javaIntroduction to basics of java
Introduction to basics of javavinay arora
 
66781291 java-lab-manual
66781291 java-lab-manual66781291 java-lab-manual
66781291 java-lab-manualLaura Popovici
 
1.1. the central concepts of automata theory
1.1. the central concepts of automata theory1.1. the central concepts of automata theory
1.1. the central concepts of automata theorySampath Kumar S
 
Class and Objects in Java
Class and Objects in JavaClass and Objects in Java
Class and Objects in JavaSpotle.ai
 
Abstraction and Encapsulation
Abstraction and EncapsulationAbstraction and Encapsulation
Abstraction and EncapsulationHaris Bin Zahid
 
Java Virtual Machine (JVM), Difference JDK, JRE & JVM
Java Virtual Machine (JVM), Difference JDK, JRE & JVMJava Virtual Machine (JVM), Difference JDK, JRE & JVM
Java Virtual Machine (JVM), Difference JDK, JRE & JVMshamnasain
 
DBMS lab manual
DBMS lab manualDBMS lab manual
DBMS lab manualmaha tce
 
oops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaoops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaCPD INDIA
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)slire
 

Was ist angesagt? (20)

Introduction to Java Programming Language
Introduction to Java Programming LanguageIntroduction to Java Programming Language
Introduction to Java Programming Language
 
String and string buffer
String and string bufferString and string buffer
String and string buffer
 
Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)Deterministic Finite Automata (DFA)
Deterministic Finite Automata (DFA)
 
Strings in Java
Strings in JavaStrings in Java
Strings in Java
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
 
2CPP14 - Abstraction
2CPP14 - Abstraction2CPP14 - Abstraction
2CPP14 - Abstraction
 
Python Dictionaries and Sets
Python Dictionaries and SetsPython Dictionaries and Sets
Python Dictionaries and Sets
 
Java basic
Java basicJava basic
Java basic
 
Introduction to basics of java
Introduction to basics of javaIntroduction to basics of java
Introduction to basics of java
 
66781291 java-lab-manual
66781291 java-lab-manual66781291 java-lab-manual
66781291 java-lab-manual
 
1.1. the central concepts of automata theory
1.1. the central concepts of automata theory1.1. the central concepts of automata theory
1.1. the central concepts of automata theory
 
Class and Objects in Java
Class and Objects in JavaClass and Objects in Java
Class and Objects in Java
 
Abstraction and Encapsulation
Abstraction and EncapsulationAbstraction and Encapsulation
Abstraction and Encapsulation
 
Features of java
Features of javaFeatures of java
Features of java
 
JVM
JVMJVM
JVM
 
Java Virtual Machine (JVM), Difference JDK, JRE & JVM
Java Virtual Machine (JVM), Difference JDK, JRE & JVMJava Virtual Machine (JVM), Difference JDK, JRE & JVM
Java Virtual Machine (JVM), Difference JDK, JRE & JVM
 
DBMS lab manual
DBMS lab manualDBMS lab manual
DBMS lab manual
 
oops concept in java | object oriented programming in java
oops concept in java | object oriented programming in javaoops concept in java | object oriented programming in java
oops concept in java | object oriented programming in java
 
NFA & DFA
NFA & DFANFA & DFA
NFA & DFA
 
Advance Java Topics (J2EE)
Advance Java Topics (J2EE)Advance Java Topics (J2EE)
Advance Java Topics (J2EE)
 

Ähnlich wie All experiment of java (20)

Unit-IV_Introduction to Java.pdf
Unit-IV_Introduction to Java.pdfUnit-IV_Introduction to Java.pdf
Unit-IV_Introduction to Java.pdf
 
Java lab zero lecture
Java  lab  zero lectureJava  lab  zero lecture
Java lab zero lecture
 
Java lab-manual
Java lab-manualJava lab-manual
Java lab-manual
 
OOPS JAVA.pdf
OOPS JAVA.pdfOOPS JAVA.pdf
OOPS JAVA.pdf
 
Industrial training
Industrial trainingIndustrial training
Industrial training
 
CORE JAVA
CORE JAVACORE JAVA
CORE JAVA
 
A CASE STUDY JAVA IS SECURE PROGRAMMING LANGUAGE
A CASE STUDY  JAVA IS SECURE PROGRAMMING LANGUAGEA CASE STUDY  JAVA IS SECURE PROGRAMMING LANGUAGE
A CASE STUDY JAVA IS SECURE PROGRAMMING LANGUAGE
 
Java Semimar Slide (Cetpa)
Java Semimar Slide (Cetpa)Java Semimar Slide (Cetpa)
Java Semimar Slide (Cetpa)
 
Java Semimar Slide (Cetpa)
Java Semimar Slide (Cetpa)Java Semimar Slide (Cetpa)
Java Semimar Slide (Cetpa)
 
Ijetcas14 385
Ijetcas14 385Ijetcas14 385
Ijetcas14 385
 
Java ms harsha
Java ms harshaJava ms harsha
Java ms harsha
 
Srgoc java
Srgoc javaSrgoc java
Srgoc java
 
Java Lecture 1
Java Lecture 1Java Lecture 1
Java Lecture 1
 
Presentation5
Presentation5Presentation5
Presentation5
 
Java programming concept
Java programming conceptJava programming concept
Java programming concept
 
Elements of Java Language
Elements of Java Language Elements of Java Language
Elements of Java Language
 
1.INTRODUCTION TO JAVA_2022 MB.ppt .
1.INTRODUCTION TO JAVA_2022 MB.ppt      .1.INTRODUCTION TO JAVA_2022 MB.ppt      .
1.INTRODUCTION TO JAVA_2022 MB.ppt .
 
Java presentation
Java presentationJava presentation
Java presentation
 
Notes of java first unit
Notes of java first unitNotes of java first unit
Notes of java first unit
 
Session 02 - Elements of Java Language
Session 02 - Elements of Java LanguageSession 02 - Elements of Java Language
Session 02 - Elements of Java Language
 

Kürzlich hochgeladen

Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphThiyagu K
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...christianmathematics
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityGeoBlogs
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...fonyou31
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdfQucHHunhnh
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 

Kürzlich hochgeladen (20)

Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Z Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot GraphZ Score,T Score, Percential Rank and Box Plot Graph
Z Score,T Score, Percential Rank and Box Plot Graph
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
Paris 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activityParis 2024 Olympic Geographies - an activity
Paris 2024 Olympic Geographies - an activity
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
Ecosystem Interactions Class Discussion Presentation in Blue Green Lined Styl...
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 

All experiment of java

  • 1. Mukesh kumar C.S.E. 1110751908 5th Semester INTRODUCTION TO JAVA Java language was developed by Sun Microsystem in the year 1991 as a part of green project. GREEN PROJECT: a research group was working to develop software to control consumer electronics devices, during this time they developed a device called " star 7" for which the operating system was planned to be developed in "c++" however one of the team member "James Gosling " was not very satisfy with the performance of c++ hence he developed a new language for start he named it as "oak" .he used to see an oak outside his office in 1995 Sun Microsystem renamed this language as java. FEATURES OF JAVA: 1) Object Oriented Programming 2) Platform Independent 3) Robust 4) Reliable, Safe & Secure 5) Compiler and Interpreter 6) Dynamic 7) Multithreaded 8) High perfomance 9) Portable 10) Simple & Easy to learn
  • 2. Mukesh kumar C.S.E. 1110751908 5th Semester Object Oriented o Object oriented throughout - no coding outside of class definitions, including main(). o An extensive class library available in the core language packages. Platform Independence o The Write-Once-Run-Anywhere ideal has not been achieved (tuning for different platforms usually required), but closer than with other languages. Robust o Exception handling built-in, strong type checking (that is, all data must be declared an explicit type), local variables must be initialized. Security o No memory pointers o Programs runs inside the virtual machine sandbox. o Array index limit checking security manager - determines what resources a class can access such as reading and writing to the local disk Compiler/Interpreter o Code is compiled to bytecodes that are interpreted by a Java virtual machines (JVM) . o This provides portability to any machine for which a virtual machine has been written. o The two steps of compilation and interpretation allow for extensive code checking and improved security. Dynamic Binding o The linking of data and methods to where they are located, is done at run-time. o New classes can be loaded while a program is running. Linking is done on the fly. o Even if libraries are recompiled, there is no need to recompile code that uses classes in those libraries. This differs from C++, which uses static binding. This can result in fragile classes for cases where linked code is changed and memory pointers then point to the wrong addresses.
  • 3. Mukesh kumar C.S.E. 1110751908 5th Semester High Performance o Interpretation of bytecode slowed performance in early versions, but advanced virtual machines with adaptive and just-in-time compilation and other techniques now typically provide performance up to 50% to 100% the speed of C++ programs. Threading o Lightweight processes, called threads, can easily be spun off to perform multiprocessing. o Can take advantage of multiprocessors where available o Great for multimedia displays. What is the Java Virtual Machine? The JVM is the software that executes Java bytecode. A Java program, written in a file with a .java extension, is compiled into class files that have a .class extension. The class files are written in bytecode. To execute these files, the computer uses the JVM to interpret the bytecode. A browser that is capable of executing Java applets has the JVM built into it. To run a Java application, the Java Runtime Environment (JRE) must be installed. The JRE contains the files in the Java Development Kit minus the development tools, only the files necessary to run a Java application are present. The bytecode is the same for all platforms, but the JVM will be different on different platforms because it needs to execute programs using the native code of the machine it is running on. Development Tools: The development tools provide everything you'll need for compiling, running, monitoring, debugging, and documenting your applications. As a new developer, the main tools you'll be using are the javac compiler, the java launcher, and the javadoc documentation tool. What is an Object Object is instance of class, it contain data as well as behavior of the functions how to manipulate that data. What is a Class Class is a collection of similar objects. A class is a blueprint or prototype from which objects are created.
  • 4. Mukesh kumar C.S.E. 1110751908 5th Semester EXPERIMENT NO.1 Aim:-- Write a program to display welcome note. class W { public static void main(String args[]) { System .out.println("welcome"); } }
  • 5. Mukesh kumar C.S.E. 1110751908 5th Semester Output:--
  • 6. Mukesh kumar C.S.E. 1110751908 5th Semester EXPERIMENT NO.2 Aim:-- Write a program to compute the circle of area. class mkk { public static void main(String args[]) { int r; r = 5; float pi = 3.14f; System.out.println(pi * r * r); } }
  • 7. Mukesh kumar C.S.E. 1110751908 5th Semester Output:--
  • 8. Mukesh kumar C.S.E. 1110751908 5th Semester EXPERIMENT NO.3 Aim:-- Write a program add two number using command line argument . class mss { public static void main(String args[]) { int a,b,c; a=Integer.parseInt(args[0]); b=Integer.parseInt(args[1]); c=a+b; System.out.println("addition="+c); } }
  • 9. Mukesh kumar C.S.E. 1110751908 5th Semester Output:--
  • 10. Mukesh kumar C.S.E. 1110751908 5th Semester EXPERIMENT NO.4 Aim:-- Write a program to display menu 1(Addition), 2(subtraction), 3(Multiplication), 4(Division). class mss { public static void main(String args[]) { int a,b,c,d; a=Integer.parseInt(args[0]); b=Integer.parseInt(args[1]); c=Integer.parseInt(args[2]); switch(a) { case 1: { d=b+c; System.out.println("addition="+d); break; } case 2: { d=b-c; System.out.println("substraction="+d); break; } case 3: { d=b*c; System.out.println("multiplication="+d); break; } case 4: { d=b/c; System.out.println("division="+d); break; } default: { System.out.println("invalid"); } } } }
  • 11. Mukesh kumar C.S.E. 1110751908 5th Semester Output:--
  • 12. Mukesh kumar C.S.E. 1110751908 5th Semester EXPERIMENT NO.5 Aim:-- Write a program to print all the odd number 1 to 50. class P { public static void main(String args[] ) { for(int i=1;i<=50;i=i+2) { System.out.println(i); } } }
  • 13. Mukesh kumar C.S.E. 1110751908 5th Semester Output:--
  • 14. Mukesh kumar C.S.E. 1110751908 5th Semester EXPERIMENT NO.6 Aim:-- Write a program to find wheather the number is prime or not. class mk { public static void main(String args[]) { int i; int no=Integer.parseInt(args[0]); for(i=2;i<=no;i++) { if(no % i==0) break; } if(no==i) { System.out.println("prime number"); } else { System.out.println("not prime number"); } } }
  • 15. Mukesh kumar C.S.E. 1110751908 5th Semester Output:--
  • 16. Mukesh kumar C.S.E. 1110751908 5th Semester EXPERIMENT NO.7 Aim:-- Write a program to show fibonsci series from 1 to 21. class ms { public static void main(String args[]) { int a=1,b=0,t; for(int i=1;i<=21;i++) { System.out.println(a); t=a+b; b=a; a=t; } } }
  • 17. Mukesh kumar C.S.E. 1110751908 5th Semester Output:--
  • 18. Mukesh kumar C.S.E. 1110751908 5th Semester EXPERIMENT NO.8 Aim:-- Write a program print sum and average of 5 number in single array . class array { public static void main(String args[]) { int a []=new int[5],i,s=0,h=0; for(i=0;i<=4;i++) a[i]=Integer.parseInt(args[i]); for(i=0;i<=4;i++) { s=s+a[i]; } System .out.println("sum is"+s); h=s/5; System .out.println("ave is"+h); } }
  • 19. Mukesh kumar C.S.E. 1110751908 5th Semester Output:--