SlideShare uma empresa Scribd logo
1 de 23
Introduction to Java Programming
R.Saravanakumar., MCA
Developer, Trainer, Consultant
Introduction
• JAVA was developed by Sun Microsystems Inc in 1991, later
acquired by Oracle Corporation.
• It was conceived by James Gosling and Patrick Naughton. It is
a simple programming language.
• Writing, compiling and debugging a program is easy in java. It
helps to create modular programs and reusable code.
Features of JAVA
• Java is a platform independent language
• Java is an Object Oriented language
– Object oriented programming is a way of organizing programs as
collection of objects, each of which represents an instance of a class.
– 4 main concepts of Object Oriented programming are:
• Abstraction
• Encapsulation
• Inheritance
• Polymorphism
Features of JAVA
• Simple
• Robust Language
• Secure
• Java is distributed
• Java is distributed
• Multithreading
• Portable
Compilation and Execution of Java Program
• To create a java code an editor such as
notepad, text pad or an IDE like eclipse can be
used.
• In the above program the class FirstJavaProgram
has public access and hence declared public.
• ‘class’ is the keyword used to create a class.
• For running stand-alone programs ‘main’ method
is needed which has a signature similar to the
one defined in the above program.
• ‘Main’ method takes an array of strings as an
argument. The name of the array can be
anything.
• To display the output, pass the string as an
argument to the method System.out.println.
Steps for compilation and Execution
• Step1: Save the source file as WelcomeApp.java.
• Step2: Open command prompt and navigate to
the directory where you have stored the file.
• Step 3: To compile, type javac
FirstJavaProgram.java and press Enter.
• Step 4: On successful compilation, you will see the command
prompt and FirstJavaProgram.class file in the same folder where
WelcomeApp.java is stored. This is the byte code of the program.
• Step 5: To execute, type java FirstJavaProgram. Do not type the
extension while executing.
• Step 6: See the output “This is my first program in java” displayed
on the console.
Common programming Errors in Java
• ‘javac’ is not recognized as an internal or external
command, operable program or batch file
• Exception in thread
“main”java.lang.NoClassDefFoundError:
FirstJavaProgram
Another Example
Interpreting the code
a) Line 1. The package FirstCode creates a folder to store the class
files generated after compilation
b) Line2. It imports the class library java.lang and its subsequent
classes
c) Line 3. Initiates a class with the name WelcomeMessage
d) Line 5. Declares a method with name printMessage
Interpreting the code
e) Line 7. Defines the actual working code of the method
f) Line 10. Initiates the class having the main method; it should bear the name of the file :
Myclass.java
g) Line 12. Declares the main method
h) Line 14. Initiates the creation of the object
i) Line 15. Calls the method printMessage () with the help of the object
j) The above code is saved and compiled to run on JVM
The programming structure
1) The programming pattern is divided into classes which has meth0d definitions
2) This assists in distributing the code into smaller units
3) The libraries can be used over and over again
4) These codes generated here can be called in another program if required
5) The memory allocation is done only after the execution of the new keyword
6) It gets easier to collect memory that does not has any future use
Java Tutorial – JVM (Java virtual Machine)
1) Class loader accepts class files
2) Compilation creates class files
3) The interim memory is required during execution
4) It consists of heaps, stacks and registers to store data
5) JRE has native methods and libraries
6) JVM runs two main threads
a) demon
b) Non-demon threads
Demon Threads
• It has been Run by JVM for itself. Used for
garbage collection. JVM decides on a thread
for being a demon thread
Non-demon threads
• main() is the initial and non-demon thread.
Other implemented threads are also non-
demon threads. The JVM is active till any non-
demon thread is active.
Execution on JVM
• 1) JVM executes Java byte codes
2) Other programming language codes if converted to adequate Java byte
code can be executed on JVM
3) JVM is different for different platforms and can also act as a platform
itself
4) JVM supports automatic error handling by intercepting the errors
which can be controlled
5) This feature is useful in platform independency and multi user ability of
Java.
Compilation
• 1) The compiler requires to know the TYPE of every CLASS used in
the program source code
2) This is done by setting a default user environment variable
CLASSPATH
3) The Javac (Java Compiler) reads the program and converts it into
byte code files called as class files
Java Source code
• 1) It essentially consists of a main() method
2) This method is public and thus can be called by any object
3) This method is also static and so can be called without instantiating the object
of the class
4) It does not return any value
5) The controlling class of every Java application usually contain a main method
6) This can be avoided to allow the class to be tested in a stand-alone mode.
7) Other methods can subsequently be called in main()
End

Mais conteúdo relacionado

Mais procurados

Genesis and Overview of Java
Genesis and Overview of Java Genesis and Overview of Java
Genesis and Overview of Java
Ravi_Kant_Sahu
 
14 file handling
14 file handling14 file handling
14 file handling
APU
 

Mais procurados (20)

Genesis and Overview of Java
Genesis and Overview of Java Genesis and Overview of Java
Genesis and Overview of Java
 
OOPS In JAVA.pptx
OOPS In JAVA.pptxOOPS In JAVA.pptx
OOPS In JAVA.pptx
 
Inheritance In Java
Inheritance In JavaInheritance In Java
Inheritance In Java
 
Exception Handling In Java
Exception Handling In JavaException Handling In Java
Exception Handling In Java
 
Introduction to java
Introduction to java Introduction to java
Introduction to java
 
Industrial Training report on java
Industrial  Training report on javaIndustrial  Training report on java
Industrial Training report on java
 
Oops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts in JavaOops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts in Java
 
OOPS with C++ | Concepts of OOPS | Introduction
OOPS with C++ | Concepts of OOPS | IntroductionOOPS with C++ | Concepts of OOPS | Introduction
OOPS with C++ | Concepts of OOPS | Introduction
 
Introduction of java
Introduction  of javaIntroduction  of java
Introduction of java
 
JAVA OOP
JAVA OOPJAVA OOP
JAVA OOP
 
Inheritance In C++ (Object Oriented Programming)
Inheritance In C++ (Object Oriented Programming)Inheritance In C++ (Object Oriented Programming)
Inheritance In C++ (Object Oriented Programming)
 
Oops in Java
Oops in JavaOops in Java
Oops in Java
 
Java project
Java projectJava project
Java project
 
Access specifier
Access specifierAccess specifier
Access specifier
 
inheritance c++
inheritance c++inheritance c++
inheritance c++
 
14 file handling
14 file handling14 file handling
14 file handling
 
Result Management System - CSE Final Year Projects
Result Management System - CSE Final Year ProjectsResult Management System - CSE Final Year Projects
Result Management System - CSE Final Year Projects
 
Object Oriented Programming
Object Oriented ProgrammingObject Oriented Programming
Object Oriented Programming
 
Object oriented programming in java
Object oriented programming in javaObject oriented programming in java
Object oriented programming in java
 
Packages in java
Packages in javaPackages in java
Packages in java
 

Semelhante a Introduction to Java Programming

A begineers guide of JAVA - Getting Started
 A begineers guide of JAVA - Getting Started A begineers guide of JAVA - Getting Started
A begineers guide of JAVA - Getting Started
Rakesh Madugula
 
JAVA_Day1_BasicIntroduction.pptx
JAVA_Day1_BasicIntroduction.pptxJAVA_Day1_BasicIntroduction.pptx
JAVA_Day1_BasicIntroduction.pptx
Murugesh33
 

Semelhante a Introduction to Java Programming (20)

OOP with Java
OOP with JavaOOP with Java
OOP with Java
 
Java introduction
Java introductionJava introduction
Java introduction
 
1 java programming- introduction
1  java programming- introduction1  java programming- introduction
1 java programming- introduction
 
Java
JavaJava
Java
 
A begineers guide of JAVA - Getting Started
 A begineers guide of JAVA - Getting Started A begineers guide of JAVA - Getting Started
A begineers guide of JAVA - Getting Started
 
Java
JavaJava
Java
 
JAVA PROGRAM CONSTRUCTS OR LANGUAGE BASICS.pptx
JAVA PROGRAM CONSTRUCTS OR LANGUAGE BASICS.pptxJAVA PROGRAM CONSTRUCTS OR LANGUAGE BASICS.pptx
JAVA PROGRAM CONSTRUCTS OR LANGUAGE BASICS.pptx
 
CORE JAVA
CORE JAVACORE JAVA
CORE JAVA
 
Java introduction
Java introductionJava introduction
Java introduction
 
Introduction to Java Programming.pdf
Introduction to Java Programming.pdfIntroduction to Java Programming.pdf
Introduction to Java Programming.pdf
 
oop unit1.pptx
oop unit1.pptxoop unit1.pptx
oop unit1.pptx
 
CS8392 OOP
CS8392 OOPCS8392 OOP
CS8392 OOP
 
Learn Java with Dr. Rifat Shahriyar
Learn Java with Dr. Rifat ShahriyarLearn Java with Dr. Rifat Shahriyar
Learn Java with Dr. Rifat Shahriyar
 
JAVA for Every one
JAVA for Every oneJAVA for Every one
JAVA for Every one
 
JAVA_Day1_BasicIntroduction.pptx
JAVA_Day1_BasicIntroduction.pptxJAVA_Day1_BasicIntroduction.pptx
JAVA_Day1_BasicIntroduction.pptx
 
JAVAPart1_BasicIntroduction.pptx
JAVAPart1_BasicIntroduction.pptxJAVAPart1_BasicIntroduction.pptx
JAVAPart1_BasicIntroduction.pptx
 
j-chap1-Basics.ppt
j-chap1-Basics.pptj-chap1-Basics.ppt
j-chap1-Basics.ppt
 
Java
JavaJava
Java
 
Top 10 Important Core Java Interview questions and answers.pdf
Top 10 Important Core Java Interview questions and answers.pdfTop 10 Important Core Java Interview questions and answers.pdf
Top 10 Important Core Java Interview questions and answers.pdf
 
1 Module 1 Introduction.pptx
1 Module 1 Introduction.pptx1 Module 1 Introduction.pptx
1 Module 1 Introduction.pptx
 

Último

TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
mohitmore19
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
masabamasaba
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
masabamasaba
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
masabamasaba
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
masabamasaba
 

Último (20)

%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
Announcing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK SoftwareAnnouncing Codolex 2.0 from GDK Software
Announcing Codolex 2.0 from GDK Software
 
TECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service providerTECUNIQUE: Success Stories: IT Service provider
TECUNIQUE: Success Stories: IT Service provider
 
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
%+27788225528 love spells in Colorado Springs Psychic Readings, Attraction sp...
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
%+27788225528 love spells in new york Psychic Readings, Attraction spells,Bri...
 
Right Money Management App For Your Financial Goals
Right Money Management App For Your Financial GoalsRight Money Management App For Your Financial Goals
Right Money Management App For Your Financial Goals
 
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdfThe Ultimate Test Automation Guide_ Best Practices and Tips.pdf
The Ultimate Test Automation Guide_ Best Practices and Tips.pdf
 
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
%in Bahrain+277-882-255-28 abortion pills for sale in Bahrain
 
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
%in Stilfontein+277-882-255-28 abortion pills for sale in Stilfontein
 
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
%+27788225528 love spells in Atlanta Psychic Readings, Attraction spells,Brin...
 
Architecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the pastArchitecture decision records - How not to get lost in the past
Architecture decision records - How not to get lost in the past
 
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa%in tembisa+277-882-255-28 abortion pills for sale in tembisa
%in tembisa+277-882-255-28 abortion pills for sale in tembisa
 
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
%+27788225528 love spells in Boston Psychic Readings, Attraction spells,Bring...
 
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park %in kempton park+277-882-255-28 abortion pills for sale in kempton park
%in kempton park+277-882-255-28 abortion pills for sale in kempton park
 
SHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions PresentationSHRMPro HRMS Software Solutions Presentation
SHRMPro HRMS Software Solutions Presentation
 
Microsoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdfMicrosoft AI Transformation Partner Playbook.pdf
Microsoft AI Transformation Partner Playbook.pdf
 
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
%+27788225528 love spells in Vancouver Psychic Readings, Attraction spells,Br...
 
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
Direct Style Effect Systems -The Print[A] Example- A Comprehension AidDirect Style Effect Systems -The Print[A] Example- A Comprehension Aid
Direct Style Effect Systems - The Print[A] Example - A Comprehension Aid
 
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
%in kaalfontein+277-882-255-28 abortion pills for sale in kaalfontein
 

Introduction to Java Programming

  • 1. Introduction to Java Programming R.Saravanakumar., MCA Developer, Trainer, Consultant
  • 2. Introduction • JAVA was developed by Sun Microsystems Inc in 1991, later acquired by Oracle Corporation. • It was conceived by James Gosling and Patrick Naughton. It is a simple programming language. • Writing, compiling and debugging a program is easy in java. It helps to create modular programs and reusable code.
  • 3. Features of JAVA • Java is a platform independent language • Java is an Object Oriented language – Object oriented programming is a way of organizing programs as collection of objects, each of which represents an instance of a class. – 4 main concepts of Object Oriented programming are: • Abstraction • Encapsulation • Inheritance • Polymorphism
  • 4. Features of JAVA • Simple • Robust Language • Secure • Java is distributed • Java is distributed • Multithreading • Portable
  • 5. Compilation and Execution of Java Program • To create a java code an editor such as notepad, text pad or an IDE like eclipse can be used.
  • 6. • In the above program the class FirstJavaProgram has public access and hence declared public. • ‘class’ is the keyword used to create a class. • For running stand-alone programs ‘main’ method is needed which has a signature similar to the one defined in the above program.
  • 7. • ‘Main’ method takes an array of strings as an argument. The name of the array can be anything. • To display the output, pass the string as an argument to the method System.out.println.
  • 8. Steps for compilation and Execution • Step1: Save the source file as WelcomeApp.java. • Step2: Open command prompt and navigate to the directory where you have stored the file. • Step 3: To compile, type javac FirstJavaProgram.java and press Enter.
  • 9. • Step 4: On successful compilation, you will see the command prompt and FirstJavaProgram.class file in the same folder where WelcomeApp.java is stored. This is the byte code of the program. • Step 5: To execute, type java FirstJavaProgram. Do not type the extension while executing. • Step 6: See the output “This is my first program in java” displayed on the console.
  • 10. Common programming Errors in Java • ‘javac’ is not recognized as an internal or external command, operable program or batch file • Exception in thread “main”java.lang.NoClassDefFoundError: FirstJavaProgram
  • 12. Interpreting the code a) Line 1. The package FirstCode creates a folder to store the class files generated after compilation b) Line2. It imports the class library java.lang and its subsequent classes c) Line 3. Initiates a class with the name WelcomeMessage d) Line 5. Declares a method with name printMessage
  • 13. Interpreting the code e) Line 7. Defines the actual working code of the method f) Line 10. Initiates the class having the main method; it should bear the name of the file : Myclass.java g) Line 12. Declares the main method h) Line 14. Initiates the creation of the object i) Line 15. Calls the method printMessage () with the help of the object j) The above code is saved and compiled to run on JVM
  • 14. The programming structure 1) The programming pattern is divided into classes which has meth0d definitions 2) This assists in distributing the code into smaller units 3) The libraries can be used over and over again 4) These codes generated here can be called in another program if required 5) The memory allocation is done only after the execution of the new keyword 6) It gets easier to collect memory that does not has any future use
  • 15. Java Tutorial – JVM (Java virtual Machine)
  • 16. 1) Class loader accepts class files 2) Compilation creates class files 3) The interim memory is required during execution 4) It consists of heaps, stacks and registers to store data 5) JRE has native methods and libraries 6) JVM runs two main threads a) demon b) Non-demon threads
  • 17. Demon Threads • It has been Run by JVM for itself. Used for garbage collection. JVM decides on a thread for being a demon thread
  • 18. Non-demon threads • main() is the initial and non-demon thread. Other implemented threads are also non- demon threads. The JVM is active till any non- demon thread is active.
  • 19. Execution on JVM • 1) JVM executes Java byte codes 2) Other programming language codes if converted to adequate Java byte code can be executed on JVM 3) JVM is different for different platforms and can also act as a platform itself 4) JVM supports automatic error handling by intercepting the errors which can be controlled 5) This feature is useful in platform independency and multi user ability of Java.
  • 20. Compilation • 1) The compiler requires to know the TYPE of every CLASS used in the program source code 2) This is done by setting a default user environment variable CLASSPATH 3) The Javac (Java Compiler) reads the program and converts it into byte code files called as class files
  • 21.
  • 22. Java Source code • 1) It essentially consists of a main() method 2) This method is public and thus can be called by any object 3) This method is also static and so can be called without instantiating the object of the class 4) It does not return any value 5) The controlling class of every Java application usually contain a main method 6) This can be avoided to allow the class to be tested in a stand-alone mode. 7) Other methods can subsequently be called in main()
  • 23. End