SlideShare uma empresa Scribd logo
1 de 25
Programming in JAVA
BY
N.RUBA
ASST.PROF/DEPT. OF CA,
BON SECOURS COLLEGE FOR WOMEN,
THANJAVUR.
1
 Overview of Java Technology
 Java as a programming language
 Java as a platform
 Short history of the development of java
 Java as a new paradigm in programming
 Features of Java
 Comparing java and other languages
 Applications and Applets
CHAPTER-2
Introduction to Java Programming
2
 A program is a series of instructions that are carried out by a computer.
 Application programming is a programming process that is aimed at
developing an application.(e.g banking, railway .,etc)
 Systems programming- is the activity of writing, amending or extending
the operating system, which is a program that runs on the computer
hardware in order to allow other applications to be run.
Introduction 3
 Java is a general-purpose high-level object oriented programming language that
provides the following characteristics:
 Simple
 Object oriented
 Interpreted•
 Architecture-neutral
 Platform independent
 Multithread
 Dynamic
 High-performance
 Distributed
 Robust
 Secure.
Java as a programming language
4
 A programming language requires either a compiler or an interpreter to
translate a code written in high-level programming language (source code)
into its machine language (objectcode) equivalent.
 But, to run a Java program, Java uses a combination of compiler and
interpreter.
 The Java compiler translates the Java program into an intermediate code called
Java byte code.
 A Java interpreter is used to run the compiled Java byte code. This allows Java
programs to run on different platforms.
 A compiled Java byte code can be executed on any computer platform on
which the Java interpreter is installed.
 For each type of computer, a different Java interpreter is required to interpret
the Java byte code.
5
 Java is a strongly typed language. That means that every variable
(or expression) has a type associated with it and the type is
known at the time of compilation.
 In Java, data type conversions do not take place
implicitly.
 There are three kinds of Java program:
 Applications These are stand-alone programs that run on a
computer.
 Applets These are programs that run on a web browser.
Appletviewer is provided to ensure that these programs run
without a web browser.
 Servlets These are programs that run at the server side

6
JAVA as a compiler and Interpreter
Object code
Java Byte
code
interpreter
Java Source
code
Compiler
7
 A software and hardware environment in which a program runs is referred
to as a platform.
 Java platform that is compatible and executes on platforms based on
different hardwares.
 Java platform consists of
 Java Virtual Machine(JVM)
 Receives bytecode files and translates them into machine language(object code)
instructions.
 E.g Unix, linux & windows
 Java Applications Programming Interface(JavaAPI)
 Collection of software components
 API grouped in the form of packages
Java as a platform 8
 Java is a result of efforts of programmers in the early 1990s to develop a portable,
secure and scalable language to be used for communication between electronic
devices.
 A team of programmers led by James Gosling of Sun microsystems developed the first
version of Java called OAK.
 Java language was meant for programming the embedded systems in consumer
electronic devices
 Since the Oak trademark was already registered with some other organization, Sun
Microsystems renamed the language Java, in January 1995.
 During the period when Oak was being developed, the computer world witnessed the
emergence of the Internet. As Internet usage became widespread, the need for a
portable,secure programming language increased.
 Java fit the bill perfectly. Initially developed for use on different electronic devices, the
language was later adapted for Internet programming, Java met all the requirements
specified for web-based applications as it can be used to writeplatform-independent
code.
History of development of Java 9
 In 1995, Sun Microsystems released the first version of the Java Development Kit (JDK)and HotJava, a
Java-enabled browser.
 HotJava was capable of running Java applicationsin the form of Java Applets embedded in web pages, a
feature since taken up by browsers from Microsoft and Netscape. Java is often described as the World
Wide Web (www) programming language.
 From the second half of the 1990s, the popularity of Java increased considerably. An important
consequence of the evolution of Java is that it has grown into a full-scale development system.
 capable of being used for developing large applications that exist outside of the web (Internet)
environment that is, all kinds of program that run on a PC), including those that make extensive use of
networking to enable communication between programs.
 Sun Microsystems are now working to further refine and develop Java language.
In addition,they are also working on other Java tools and applications, Prominent among these are
thefollowing:
 Java Beans--the Java object component technology
 JavaServer-a complete web server application written in Java, supporting serviets.•
 JDBC-Java Database Connectivity, providing a Java-based interface to SQL databases.
 Java Workshop a Java programming environment for developing Java programs which isitself
written in Java.
 To get the latest updates on other Java tools and applications, readers can refer to the website of
Sun Microsystems-http://www.sun.com.
10
There are a number of other factors that are attributed to the rise in popularity of Java.
These include the following
 Familiarity of Java as a programming language to users of other popular languages,
notably C++ and Smalltalk: due to this factor, users find it simple and easy to relate
and comprehend.
 The Java development kit is offered free of cost
 This factor allows potential users to try out language with minimal start-up cost
 Its availability: Java is offered as freely downloadable software from the Sun
Microsystems website
 The software is also available on other websites
 Finally, its timing: Java gained popularity as it emerged at the right time when the
Internet was in its nascent stage and was all set to grow in popularity
Java as a new paradigm in programming
11
Features of Java
It is simple, it is highly robust, platform independent and portable
 Java is simple and Object Oriented Language
 Java is highly secure
 Allows to develop highly reliable software applications.
 Provides compile time checking and run time checking.
 Java makes memory management extremely simple
12
 Java compiler generates a byte code.
 Bytecode-special format
 Java byte code written in hexadecimal characters
 Byte code is completely platform- independent, only the interpreter and a few
native libraries need to be ported to get java run on a new computer or OS.
 The architectural –neutral and portable language platform of java is known as JVM-
Java Virtual Machine.
 Java shows a high performance
 Java is interpreted, threaded and dynamic
 Providing multi threading capability
 Multithreading in Java is a process of executing multiple
threads simultaneously.
 A thread is a lightweight sub-process, the smallest unit of processing.
Multiprocessing and multithreading, both are used to achieve multitasking.
13
 Java is dynamically linked
 Does not have an explicit link space.
 Java source code is divided into .java files
 Compiler complies these into .class files
 Other features of java – no pointers, all memory access is trusted
automatic memory allocation and deallocation
14
Comparing Java and other Languages
 Java is similar to C and C++, but is strongly typed
 Java is dynamically linked
 Java is case sensitive
 Java does not support pointer
 Java allows single inheritance
 Multiple inheritance can be achieved in java through interfaces
 Java is compiled and interpreted language
15
Applications and Applets
 Java program are compiled into applet or application
 Application are stand-alone program executed by virtual machine
 Applets are intended to be loaded into and interpreted by a browser, such
as Netscape or Internet explorer
 A byte code cannot be modified by a programmer
16
Java Applet
 Applet is a special type of program that is embedded in the webpage to generate the
dynamic content. It runs inside the browser and works at client side.
Advantage of Applet
 There are many advantages of applet. They are as follows:
 It works at client side so less response time.
 Secured
 It can be executed by browsers running under many platforms, including Linux, Windows,
Mac Os etc.
Drawback of Applet
 Plugin is required at client browser to execute applet.
How to run an Applet?
 There are two ways to run an applet
 By html file.
 By appletViewer tool (for testing purpose).
17
example of Applet by html file:
To execute the applet by html file, create an applet and compile it. After that create an
html file and place the applet code in html file. Now click the html file.
//First.java
import java.applet.Applet;
import java.awt.Graphics;
public class First extends Applet{
public void paint(Graphics g){
g.drawString("welcome",150,150);
}
}
Note: class must be public because its object is created by Java Plugin software that
resides on the browser.
18
myapplet.html
<html>
<body>
<applet code="First.class" width="300" height="300">
</applet>
</body>
</html>
 To execute the applet by html file, create an applet and compile it. After that create an html
file and place the applet code in html file. Now click the html file.
19
Simple example of Applet by appletviewer tool:
To execute the applet by appletviewer tool, create an applet that contains applet tag in comment and
compile it. After that run it by: appletviewer First.java. Now Html file is not required but it is for testing
purpose only.
//First.java
import java.applet.Applet;
import java.awt.Graphics;
public class First extends Applet{
public void paint(Graphics g){
g.drawString("welcome to applet",150,150);
}
}
/*
<applet code="First.class" width="300" height="300">
</applet>
*/
20
 To execute the applet by appletviewer tool, write in command prompt:
 c:>javac First.java
 c:>appletviewer First.java
21
 Special features of java program
 Access specifier
 Constructors
 Static
 The method main()
 The signature of the main method is
 Public staticvoid main(String args[])
22
Step 1:
Write a program on the notepad and save it with .java (for
example, DemoFile.java) extension.
class Demofile
{
public static void main(String args[]) {
System.out.println("Hello!");
System.out.println("Java");
}
}
23
Step 2:
Open Command Prompt.
Step 3:
Set the directory in which the .java file is saved. In our case, the .java
is saved in C:demo.
Step 4:
Use the javac command to compile the Java program. It generates a
.class file in the same folder. It also shows an error if any.
javac Demofile.java
step 5:
Use the following command to run the Java program:
c:> cd demo
c:> demo> javac Demofile.Java
c:> java Demofile
output:
Hello! Java
24
Thank you
25

Mais conteúdo relacionado

Mais procurados

Software environment
Software environmentSoftware environment
Software environmentKinnudj Amee
 
C,c++,java,php,.net training institute in delhi, best training institute for ...
C,c++,java,php,.net training institute in delhi, best training institute for ...C,c++,java,php,.net training institute in delhi, best training institute for ...
C,c++,java,php,.net training institute in delhi, best training institute for ...MCM COmpetitive Classes
 
(Ebook pdf) java programming language basics
(Ebook pdf)   java programming language basics(Ebook pdf)   java programming language basics
(Ebook pdf) java programming language basicsRaffaella D'angelo
 
A Comparison of .NET Framework vs. Java Virtual Machine
A Comparison of .NET Framework vs. Java Virtual MachineA Comparison of .NET Framework vs. Java Virtual Machine
A Comparison of .NET Framework vs. Java Virtual MachineAbdelrahman Hosny
 
Structure programming – Java Programming – Theory
Structure programming – Java Programming – TheoryStructure programming – Java Programming – Theory
Structure programming – Java Programming – TheoryOXUS 20
 
Presentación rs232 java
Presentación rs232 javaPresentación rs232 java
Presentación rs232 javaJohn Rojas
 
Java (Part 2) unit 1
Java (Part 2) unit 1Java (Part 2) unit 1
Java (Part 2) unit 1SURBHI SAROHA
 
Core Java
Core JavaCore Java
Core JavaNA
 

Mais procurados (19)

Software environment
Software environmentSoftware environment
Software environment
 
Java Programming Basics
Java Programming BasicsJava Programming Basics
Java Programming Basics
 
Software requirement
Software requirementSoftware requirement
Software requirement
 
perl-java
perl-javaperl-java
perl-java
 
C,c++,java,php,.net training institute in delhi, best training institute for ...
C,c++,java,php,.net training institute in delhi, best training institute for ...C,c++,java,php,.net training institute in delhi, best training institute for ...
C,c++,java,php,.net training institute in delhi, best training institute for ...
 
Features of java
Features of javaFeatures of java
Features of java
 
Ch2
Ch2Ch2
Ch2
 
(Ebook pdf) java programming language basics
(Ebook pdf)   java programming language basics(Ebook pdf)   java programming language basics
(Ebook pdf) java programming language basics
 
A Comparison of .NET Framework vs. Java Virtual Machine
A Comparison of .NET Framework vs. Java Virtual MachineA Comparison of .NET Framework vs. Java Virtual Machine
A Comparison of .NET Framework vs. Java Virtual Machine
 
Java Programming
Java ProgrammingJava Programming
Java Programming
 
Java
JavaJava
Java
 
Structure programming – Java Programming – Theory
Structure programming – Java Programming – TheoryStructure programming – Java Programming – Theory
Structure programming – Java Programming – Theory
 
Java features
Java featuresJava features
Java features
 
Presentación rs232 java
Presentación rs232 javaPresentación rs232 java
Presentación rs232 java
 
Java (Part 2) unit 1
Java (Part 2) unit 1Java (Part 2) unit 1
Java (Part 2) unit 1
 
J introtojava1-pdf
J introtojava1-pdfJ introtojava1-pdf
J introtojava1-pdf
 
Core Java
Core JavaCore Java
Core Java
 
JAVA First Day
JAVA First DayJAVA First Day
JAVA First Day
 
JAVA Program Examples
JAVA Program ExamplesJAVA Program Examples
JAVA Program Examples
 

Semelhante a Java Programming Guide for Beginners

Chapter 1 introduction to java technology
Chapter 1 introduction to java technologyChapter 1 introduction to java technology
Chapter 1 introduction to java technologysshhzap
 
JAVA ALL 5 MODULE NOTES.pptx
JAVA ALL 5 MODULE NOTES.pptxJAVA ALL 5 MODULE NOTES.pptx
JAVA ALL 5 MODULE NOTES.pptxDrPreethiD1
 
Core Java Slides
Core Java SlidesCore Java Slides
Core Java SlidesVinit Vyas
 
Java & J2EE Struts with Hibernate Framework
Java & J2EE Struts with Hibernate FrameworkJava & J2EE Struts with Hibernate Framework
Java & J2EE Struts with Hibernate FrameworkMohit Belwal
 
java introduction.docx
java introduction.docxjava introduction.docx
java introduction.docxvikasbagra9887
 
JAVA PROGRAMMING-Unit I - Final PPT.pptx
JAVA PROGRAMMING-Unit I - Final PPT.pptxJAVA PROGRAMMING-Unit I - Final PPT.pptx
JAVA PROGRAMMING-Unit I - Final PPT.pptxSuganthiDPSGRKCW
 
0f0cef_1dac552af56c4338ab0672859199e693.pdf
0f0cef_1dac552af56c4338ab0672859199e693.pdf0f0cef_1dac552af56c4338ab0672859199e693.pdf
0f0cef_1dac552af56c4338ab0672859199e693.pdfDeepakChaudhriAmbali
 
Notes of java first unit
Notes of java first unitNotes of java first unit
Notes of java first unitgowher172236
 
Introduction to Java Programming.pdf
Introduction to Java Programming.pdfIntroduction to Java Programming.pdf
Introduction to Java Programming.pdfAdiseshaK
 
Java Evolution-2.pdf
Java Evolution-2.pdfJava Evolution-2.pdf
Java Evolution-2.pdfkumari36
 
MODULE_1_The History and Evolution of Java.pptx
MODULE_1_The History and Evolution of Java.pptxMODULE_1_The History and Evolution of Java.pptx
MODULE_1_The History and Evolution of Java.pptxVeerannaKotagi1
 
Java Tutorial to Learn Java Programming
Java Tutorial to Learn Java ProgrammingJava Tutorial to Learn Java Programming
Java Tutorial to Learn Java Programmingbusiness Corporate
 
TechSearchWeb Tutorials.pdf
TechSearchWeb Tutorials.pdfTechSearchWeb Tutorials.pdf
TechSearchWeb Tutorials.pdfTechSearchWeb
 

Semelhante a Java Programming Guide for Beginners (20)

Chapter 1 introduction to java technology
Chapter 1 introduction to java technologyChapter 1 introduction to java technology
Chapter 1 introduction to java technology
 
JAVA ALL 5 MODULE NOTES.pptx
JAVA ALL 5 MODULE NOTES.pptxJAVA ALL 5 MODULE NOTES.pptx
JAVA ALL 5 MODULE NOTES.pptx
 
Core Java Slides
Core Java SlidesCore Java Slides
Core Java Slides
 
Java & J2EE Struts with Hibernate Framework
Java & J2EE Struts with Hibernate FrameworkJava & J2EE Struts with Hibernate Framework
Java & J2EE Struts with Hibernate Framework
 
Core java slides
Core java slidesCore java slides
Core java slides
 
java introduction.docx
java introduction.docxjava introduction.docx
java introduction.docx
 
Java presentation
Java presentationJava presentation
Java presentation
 
Unit1 JAVA.pptx
Unit1 JAVA.pptxUnit1 JAVA.pptx
Unit1 JAVA.pptx
 
Java features
Java  features Java  features
Java features
 
JAVA PROGRAMMING-Unit I - Final PPT.pptx
JAVA PROGRAMMING-Unit I - Final PPT.pptxJAVA PROGRAMMING-Unit I - Final PPT.pptx
JAVA PROGRAMMING-Unit I - Final PPT.pptx
 
Core Java-1 (1).pdf
Core Java-1 (1).pdfCore Java-1 (1).pdf
Core Java-1 (1).pdf
 
0f0cef_1dac552af56c4338ab0672859199e693.pdf
0f0cef_1dac552af56c4338ab0672859199e693.pdf0f0cef_1dac552af56c4338ab0672859199e693.pdf
0f0cef_1dac552af56c4338ab0672859199e693.pdf
 
Notes of java first unit
Notes of java first unitNotes of java first unit
Notes of java first unit
 
JAVA FEATURES
JAVA FEATURESJAVA FEATURES
JAVA FEATURES
 
Introduction to Java Programming.pdf
Introduction to Java Programming.pdfIntroduction to Java Programming.pdf
Introduction to Java Programming.pdf
 
Java Evolution-2.pdf
Java Evolution-2.pdfJava Evolution-2.pdf
Java Evolution-2.pdf
 
MODULE_1_The History and Evolution of Java.pptx
MODULE_1_The History and Evolution of Java.pptxMODULE_1_The History and Evolution of Java.pptx
MODULE_1_The History and Evolution of Java.pptx
 
Java Tutorial to Learn Java Programming
Java Tutorial to Learn Java ProgrammingJava Tutorial to Learn Java Programming
Java Tutorial to Learn Java Programming
 
TechSearchWeb Tutorials.pdf
TechSearchWeb Tutorials.pdfTechSearchWeb Tutorials.pdf
TechSearchWeb Tutorials.pdf
 
Java
JavaJava
Java
 

Mais de RubaNagarajan

Computer graphics-CRT.pptx
Computer graphics-CRT.pptxComputer graphics-CRT.pptx
Computer graphics-CRT.pptxRubaNagarajan
 
Matrix representation- CG.pptx
Matrix representation- CG.pptxMatrix representation- CG.pptx
Matrix representation- CG.pptxRubaNagarajan
 
Personality development.pptx
Personality development.pptxPersonality development.pptx
Personality development.pptxRubaNagarajan
 
TRANSFORMATION-CG.pptx
TRANSFORMATION-CG.pptxTRANSFORMATION-CG.pptx
TRANSFORMATION-CG.pptxRubaNagarajan
 
dda algorithm-cg.pptx
dda algorithm-cg.pptxdda algorithm-cg.pptx
dda algorithm-cg.pptxRubaNagarajan
 
line attributes.pptx
line attributes.pptxline attributes.pptx
line attributes.pptxRubaNagarajan
 
Java files and io streams
Java files and io streamsJava files and io streams
Java files and io streamsRubaNagarajan
 
Java -Exception handlingunit-iv
Java -Exception handlingunit-ivJava -Exception handlingunit-iv
Java -Exception handlingunit-ivRubaNagarajan
 
Introduction to Java -unit-1
Introduction to Java -unit-1Introduction to Java -unit-1
Introduction to Java -unit-1RubaNagarajan
 
Working principles of internet
Working principles of internetWorking principles of internet
Working principles of internetRubaNagarajan
 
Virtualization in cloud computing
Virtualization in cloud computingVirtualization in cloud computing
Virtualization in cloud computingRubaNagarajan
 
Cloud computing technology
Cloud computing technologyCloud computing technology
Cloud computing technologyRubaNagarajan
 

Mais de RubaNagarajan (19)

Computer graphics-CRT.pptx
Computer graphics-CRT.pptxComputer graphics-CRT.pptx
Computer graphics-CRT.pptx
 
Matrix representation- CG.pptx
Matrix representation- CG.pptxMatrix representation- CG.pptx
Matrix representation- CG.pptx
 
Personality development.pptx
Personality development.pptxPersonality development.pptx
Personality development.pptx
 
TRANSFORMATION-CG.pptx
TRANSFORMATION-CG.pptxTRANSFORMATION-CG.pptx
TRANSFORMATION-CG.pptx
 
dda algorithm-cg.pptx
dda algorithm-cg.pptxdda algorithm-cg.pptx
dda algorithm-cg.pptx
 
line attributes.pptx
line attributes.pptxline attributes.pptx
line attributes.pptx
 
Java files and io streams
Java files and io streamsJava files and io streams
Java files and io streams
 
Java -Exception handlingunit-iv
Java -Exception handlingunit-ivJava -Exception handlingunit-iv
Java -Exception handlingunit-iv
 
Java Programming
Java Programming Java Programming
Java Programming
 
Introduction to Java -unit-1
Introduction to Java -unit-1Introduction to Java -unit-1
Introduction to Java -unit-1
 
Constructors in C++
Constructors in C++Constructors in C++
Constructors in C++
 
Risks in cc
Risks in ccRisks in cc
Risks in cc
 
Dreamweaver
DreamweaverDreamweaver
Dreamweaver
 
Working principles of internet
Working principles of internetWorking principles of internet
Working principles of internet
 
Coreldraw
CoreldrawCoreldraw
Coreldraw
 
C programming
C programmingC programming
C programming
 
OPERATING SYSTEM
OPERATING SYSTEMOPERATING SYSTEM
OPERATING SYSTEM
 
Virtualization in cloud computing
Virtualization in cloud computingVirtualization in cloud computing
Virtualization in cloud computing
 
Cloud computing technology
Cloud computing technologyCloud computing technology
Cloud computing technology
 

Último

Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionSafetyChain Software
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)eniolaolutunde
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...EduSkills OECD
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfchloefrazer622
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdfSoniaTolstoy
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxSayali Powar
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13Steve Thomason
 
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
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Educationpboyjonauth
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application ) Sakshi Ghasle
 
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
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxRoyAbrique
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesFatimaKhan178732
 

Último (20)

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"
 
Mastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory InspectionMastering the Unannounced Regulatory Inspection
Mastering the Unannounced Regulatory Inspection
 
Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)Software Engineering Methodologies (overview)
Software Engineering Methodologies (overview)
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
Presentation by Andreas Schleicher Tackling the School Absenteeism Crisis 30 ...
 
Arihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdfArihant handbook biology for class 11 .pdf
Arihant handbook biology for class 11 .pdf
 
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"
 
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdfBASLIQ CURRENT LOOKBOOK  LOOKBOOK(1) (1).pdf
BASLIQ CURRENT LOOKBOOK LOOKBOOK(1) (1).pdf
 
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptxPOINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
POINT- BIOCHEMISTRY SEM 2 ENZYMES UNIT 5.pptx
 
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
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13The Most Excellent Way | 1 Corinthians 13
The Most Excellent Way | 1 Corinthians 13
 
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...
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
Introduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher EducationIntroduction to ArtificiaI Intelligence in Higher Education
Introduction to ArtificiaI Intelligence in Higher Education
 
Hybridoma Technology ( Production , Purification , and Application )
Hybridoma Technology  ( Production , Purification , and Application  ) Hybridoma Technology  ( Production , Purification , and Application  )
Hybridoma Technology ( Production , Purification , and Application )
 
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
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptxContemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
Contemporary philippine arts from the regions_PPT_Module_12 [Autosaved] (1).pptx
 
Separation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and ActinidesSeparation of Lanthanides/ Lanthanides and Actinides
Separation of Lanthanides/ Lanthanides and Actinides
 

Java Programming Guide for Beginners

  • 1. Programming in JAVA BY N.RUBA ASST.PROF/DEPT. OF CA, BON SECOURS COLLEGE FOR WOMEN, THANJAVUR. 1
  • 2.  Overview of Java Technology  Java as a programming language  Java as a platform  Short history of the development of java  Java as a new paradigm in programming  Features of Java  Comparing java and other languages  Applications and Applets CHAPTER-2 Introduction to Java Programming 2
  • 3.  A program is a series of instructions that are carried out by a computer.  Application programming is a programming process that is aimed at developing an application.(e.g banking, railway .,etc)  Systems programming- is the activity of writing, amending or extending the operating system, which is a program that runs on the computer hardware in order to allow other applications to be run. Introduction 3
  • 4.  Java is a general-purpose high-level object oriented programming language that provides the following characteristics:  Simple  Object oriented  Interpreted•  Architecture-neutral  Platform independent  Multithread  Dynamic  High-performance  Distributed  Robust  Secure. Java as a programming language 4
  • 5.  A programming language requires either a compiler or an interpreter to translate a code written in high-level programming language (source code) into its machine language (objectcode) equivalent.  But, to run a Java program, Java uses a combination of compiler and interpreter.  The Java compiler translates the Java program into an intermediate code called Java byte code.  A Java interpreter is used to run the compiled Java byte code. This allows Java programs to run on different platforms.  A compiled Java byte code can be executed on any computer platform on which the Java interpreter is installed.  For each type of computer, a different Java interpreter is required to interpret the Java byte code. 5
  • 6.  Java is a strongly typed language. That means that every variable (or expression) has a type associated with it and the type is known at the time of compilation.  In Java, data type conversions do not take place implicitly.  There are three kinds of Java program:  Applications These are stand-alone programs that run on a computer.  Applets These are programs that run on a web browser. Appletviewer is provided to ensure that these programs run without a web browser.  Servlets These are programs that run at the server side  6
  • 7. JAVA as a compiler and Interpreter Object code Java Byte code interpreter Java Source code Compiler 7
  • 8.  A software and hardware environment in which a program runs is referred to as a platform.  Java platform that is compatible and executes on platforms based on different hardwares.  Java platform consists of  Java Virtual Machine(JVM)  Receives bytecode files and translates them into machine language(object code) instructions.  E.g Unix, linux & windows  Java Applications Programming Interface(JavaAPI)  Collection of software components  API grouped in the form of packages Java as a platform 8
  • 9.  Java is a result of efforts of programmers in the early 1990s to develop a portable, secure and scalable language to be used for communication between electronic devices.  A team of programmers led by James Gosling of Sun microsystems developed the first version of Java called OAK.  Java language was meant for programming the embedded systems in consumer electronic devices  Since the Oak trademark was already registered with some other organization, Sun Microsystems renamed the language Java, in January 1995.  During the period when Oak was being developed, the computer world witnessed the emergence of the Internet. As Internet usage became widespread, the need for a portable,secure programming language increased.  Java fit the bill perfectly. Initially developed for use on different electronic devices, the language was later adapted for Internet programming, Java met all the requirements specified for web-based applications as it can be used to writeplatform-independent code. History of development of Java 9
  • 10.  In 1995, Sun Microsystems released the first version of the Java Development Kit (JDK)and HotJava, a Java-enabled browser.  HotJava was capable of running Java applicationsin the form of Java Applets embedded in web pages, a feature since taken up by browsers from Microsoft and Netscape. Java is often described as the World Wide Web (www) programming language.  From the second half of the 1990s, the popularity of Java increased considerably. An important consequence of the evolution of Java is that it has grown into a full-scale development system.  capable of being used for developing large applications that exist outside of the web (Internet) environment that is, all kinds of program that run on a PC), including those that make extensive use of networking to enable communication between programs.  Sun Microsystems are now working to further refine and develop Java language. In addition,they are also working on other Java tools and applications, Prominent among these are thefollowing:  Java Beans--the Java object component technology  JavaServer-a complete web server application written in Java, supporting serviets.•  JDBC-Java Database Connectivity, providing a Java-based interface to SQL databases.  Java Workshop a Java programming environment for developing Java programs which isitself written in Java.  To get the latest updates on other Java tools and applications, readers can refer to the website of Sun Microsystems-http://www.sun.com. 10
  • 11. There are a number of other factors that are attributed to the rise in popularity of Java. These include the following  Familiarity of Java as a programming language to users of other popular languages, notably C++ and Smalltalk: due to this factor, users find it simple and easy to relate and comprehend.  The Java development kit is offered free of cost  This factor allows potential users to try out language with minimal start-up cost  Its availability: Java is offered as freely downloadable software from the Sun Microsystems website  The software is also available on other websites  Finally, its timing: Java gained popularity as it emerged at the right time when the Internet was in its nascent stage and was all set to grow in popularity Java as a new paradigm in programming 11
  • 12. Features of Java It is simple, it is highly robust, platform independent and portable  Java is simple and Object Oriented Language  Java is highly secure  Allows to develop highly reliable software applications.  Provides compile time checking and run time checking.  Java makes memory management extremely simple 12
  • 13.  Java compiler generates a byte code.  Bytecode-special format  Java byte code written in hexadecimal characters  Byte code is completely platform- independent, only the interpreter and a few native libraries need to be ported to get java run on a new computer or OS.  The architectural –neutral and portable language platform of java is known as JVM- Java Virtual Machine.  Java shows a high performance  Java is interpreted, threaded and dynamic  Providing multi threading capability  Multithreading in Java is a process of executing multiple threads simultaneously.  A thread is a lightweight sub-process, the smallest unit of processing. Multiprocessing and multithreading, both are used to achieve multitasking. 13
  • 14.  Java is dynamically linked  Does not have an explicit link space.  Java source code is divided into .java files  Compiler complies these into .class files  Other features of java – no pointers, all memory access is trusted automatic memory allocation and deallocation 14
  • 15. Comparing Java and other Languages  Java is similar to C and C++, but is strongly typed  Java is dynamically linked  Java is case sensitive  Java does not support pointer  Java allows single inheritance  Multiple inheritance can be achieved in java through interfaces  Java is compiled and interpreted language 15
  • 16. Applications and Applets  Java program are compiled into applet or application  Application are stand-alone program executed by virtual machine  Applets are intended to be loaded into and interpreted by a browser, such as Netscape or Internet explorer  A byte code cannot be modified by a programmer 16
  • 17. Java Applet  Applet is a special type of program that is embedded in the webpage to generate the dynamic content. It runs inside the browser and works at client side. Advantage of Applet  There are many advantages of applet. They are as follows:  It works at client side so less response time.  Secured  It can be executed by browsers running under many platforms, including Linux, Windows, Mac Os etc. Drawback of Applet  Plugin is required at client browser to execute applet. How to run an Applet?  There are two ways to run an applet  By html file.  By appletViewer tool (for testing purpose). 17
  • 18. example of Applet by html file: To execute the applet by html file, create an applet and compile it. After that create an html file and place the applet code in html file. Now click the html file. //First.java import java.applet.Applet; import java.awt.Graphics; public class First extends Applet{ public void paint(Graphics g){ g.drawString("welcome",150,150); } } Note: class must be public because its object is created by Java Plugin software that resides on the browser. 18
  • 19. myapplet.html <html> <body> <applet code="First.class" width="300" height="300"> </applet> </body> </html>  To execute the applet by html file, create an applet and compile it. After that create an html file and place the applet code in html file. Now click the html file. 19
  • 20. Simple example of Applet by appletviewer tool: To execute the applet by appletviewer tool, create an applet that contains applet tag in comment and compile it. After that run it by: appletviewer First.java. Now Html file is not required but it is for testing purpose only. //First.java import java.applet.Applet; import java.awt.Graphics; public class First extends Applet{ public void paint(Graphics g){ g.drawString("welcome to applet",150,150); } } /* <applet code="First.class" width="300" height="300"> </applet> */ 20
  • 21.  To execute the applet by appletviewer tool, write in command prompt:  c:>javac First.java  c:>appletviewer First.java 21
  • 22.  Special features of java program  Access specifier  Constructors  Static  The method main()  The signature of the main method is  Public staticvoid main(String args[]) 22
  • 23. Step 1: Write a program on the notepad and save it with .java (for example, DemoFile.java) extension. class Demofile { public static void main(String args[]) { System.out.println("Hello!"); System.out.println("Java"); } } 23
  • 24. Step 2: Open Command Prompt. Step 3: Set the directory in which the .java file is saved. In our case, the .java is saved in C:demo. Step 4: Use the javac command to compile the Java program. It generates a .class file in the same folder. It also shows an error if any. javac Demofile.java step 5: Use the following command to run the Java program: c:> cd demo c:> demo> javac Demofile.Java c:> java Demofile output: Hello! Java 24