SlideShare uma empresa Scribd logo
1 de 33
Java
By Mr. Zeeshan Alam Khan
Introduction to Java
• Java is one of the world's most important and widely used
computer languages, and it has held this distinction for many
years.
• As of 2018, Java is one of the most popular programming
languages in use, particularly for client-server web applications,
with a reported 9 million developers using and working on it.
Creation Of Java
• Java was developed by James Ghosling, Patrick Naughton, Mike
Sheridan at Sun Microsystems Inc. in 1991. It took 18 months to
develop the first working version.
• The initial name was Oak but it was renamed to Java in 1995 as
OAK was a registered trademark of another Tech company.
• Java was initially launched as Java 1.0 and the current version of
java is java 1.9.
Application of Java
• Java is widely used in every corner of world and of human life. Java
is not only used in software's but is also widely used in designing
hardware controlling software components. There are more than 930
million JRE downloads each year and 3 billion mobile phones run
java.
• Following are some other usage of Java :
• Developing Desktop Applications
• Web Applications like Linkedin.com, Snapdeal.com etc
• Mobile Operating System like Android
• Embedded Systems
• Robotics and games etc.
Setup Java Environment
• For running Java programs in your system you will have to
download and install JDK kit from here(current version is jdk
1.9).
Java Features
• Simple
• Object Oriented
• Platform-Independent
• Robust
• Secure
• Multi-Threading
• Architectural Neutral
• Portable
• High-Performance
Introduction to JVM
• Java virtual Machine(JVM) is a virtual Machine that provides
runtime environment to execute java byte code. The JVM
doesn't understand Java typo, that's why you compile your
*.java files to obtain *.class files that contain the bytecodes
understandable by the JVM.
• JVM control execution of every Java program. It enables
features such as automated exception handling, Garbage-
collected heap.
JVM Architecture
JVM Components
• Class Loader : Class loader loads the Class for execution.
• Method area : Stores pre-class structure as constant pool.
• Heap : Heap is in which objects are allocated.
• Stack : Local variables and partial results are store here. Each thread has a
private JVM stack created when the thread is created.
• Program register : Program register holds the address of JVM instruction
currently being executed.
• Native method stack : It contains all native used in application.
• Executive Engine : Execution engine controls the execute of instructions
contained in the methods of the classes.
• Native Method Interface : Native method interface gives an interface between
java code and native code during execution.
• Native Method Libraries : Native Libraries consist of files required for the
execution of native code.
Differences between JDK JRE and JVM
• JRE : The Java Runtime Environment (JRE) provides the
libraries, the Java Virtual Machine, and other components to
run applets and applications written in the Java programming
language. JRE does not contain tools and utilities such as
compilers or debuggers for developing applets and applications.
Differences between JDK JRE and JVM
• JDK : The JDK also called Java Development Kit is a superset of
the JRE, and contains everything that is in the JRE, plus tools
such as the compilers and debuggers necessary for developing
applets and applications.
First Java Program
class Hello
{
public static void main(String[] args)
{
System.out.println ("Hello World program");
}
}
First Java Program-Explanation
• class : class keyword is used to declare classes in Java
• public : It is an access specifier. Public means this function is visible to all.
• static : static is again a keyword used to make a function static. To execute a static function you
do not have to create an Object of the class. The main() method here is called by JVM, without
creating any object for class.
• void : It is the return type, meaning this function will not return anything.
• main : main() method is the most important method in a Java program. This is the method which
is executed, hence all the logic must be inside the main() method. If a java class is not having a
main() method, it causes compilation error.
• String[] args : This represents an array whose type is String and name is args. We will discuss
more about array in Java Array section.
• System.out.println : This is used to print anything on the console like printf in C language
Steps to Compile and Run your first Java
program
Step 1: Open a text editor and write the code as above.
Step 2: Save the file as Hello.java
Step 3: Open command prompt and go to the directory where you saved your first
java program assuming it is saved in C:
Step 4: Type javac Hello.java and press Return(Enter KEY) to compile your code.
This command will call the Java Compiler asking it to compile the specified file. If
there are no errors in the code the command prompt will take you to the next line.
Step 5: Now type java Hello on command prompt to run your program.
Step 6: You will be able to see Hello world program printed on your command
prompt
What happens at Runtime
What happens at Runtime..contd
• After writing your Java program, when you will try to compile it. Compiler will
perform some compilation operation on your program.
• Once it is compiled successfully byte code(.class file) is generated by the compiler.
• After compiling when you will try to run the byte code(.class file), the following steps
are performed at runtime:-
• Class loader loads the java class. It is subsystem of JVM Java Virtual machine.
• Byte Code verifier checks the code fragments for illegal codes that can violate access
right to the object.
• Interpreter reads the byte code stream and then executes the instructions, step by
step.
Data Types in Java
• Java language has a rich implementation of data types. Data
types specify size and the type of values that can be stored in
an identifier.
• In java, data types are classified into two catagories :
• Primitive Data type
• Non-Primitive Data type
Primitive Data type
• A primitive data type can be of eight types :
• char
• boolean
• byte
• short
• int
• long
• float
• double
Integer group
This group includes byte, short, int, long
• byte : It is 1 byte(8-bits) integer data type. Value range from -128 to 127.
Default value zero. example: byte b=10;
• short : It is 2 bytes(16-bits) integer data type. Value range from -32768 to
32767. Default value zero. example: short s=11;
• int : It is 4 bytes(32-bits) integer data type. Value range from -2147483648
to 2147483647. Default value zero. example: int i=10;
• long : It is 8 bytes(64-bits) integer data type. Value range from -
9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. Default value
zero. example: long l=100012;
Floating-Point Number
This group includes float, double
• float : It is 4 bytes(32-bits) float data type. Default value 0.0f.
example: float ff=10.3f;
• double : It is 8 bytes(64-bits) float data type. Default value
0.0d.
example: double db=11.123;
Characters
• This group represent char, which represent symbols in a
character set, like letters and numbers.
• char : It is 2 bytes(16-bits) unsigned unicode character. Range 0
to 65,535.
example: char c='a';
Boolean
• This group represent boolean, which is a special type for
representing true/false values. They are defined constant of the
language.
• example: boolean b=true;
Non-Primitive(Reference) Data type
• A reference data type is used to refer to an object. A reference
variable is declare to be of specific and that type can never be
change. We will talk a lot more about reference data type later
in Classes and Object lesson.
Identifiers in Java
• All Java components require names. Name used for classes,
methods, interfaces and variables are called Identifier. Identifier
must follow some rules. Here are the rules:
• All identifiers must start with either a letter( a to z or A to Z ) or
currency character($) or an underscore.
• After the first character, an identifier can have any combination of
characters.
• A Java keyword cannot be used as an identifier.
• Identifiers in Java are case sensitive, foo and Foo are two different
identifiers.
Variables
• When we want to store any information, we store it in an address of
the computer. Instead of remembering the complex address where
we have stored our information, we name that address. The naming
of an address is known as variable. Variable is the name of memory
location.
• Java Programming language defines mainly three kind of variables.
• Instance variables
• Static Variables
• Local Variables
Instance variables
• Instance variables are variables that are declare inside a class but
outside any method, constructor or block. Instance variable are
also variable of object commonly known as field or property. They
are referred as object variable. Each object has its own copy of
each variable and thus, it doesn't effect the instance variable if
one object changes the value of the variable.
class Student
{
String name;
int age;
}
Static variables
• Static are class variables declared with static keyword. Static
variables are initialized only once. Static variables are also used in
declaring constant along with final keyword.
class Student {
String name;
int age;
static int instituteCode=1101;
}
Additional points on static variables:
• static variable are also known as class variable.
• static means to remain constant.
• In Java, it means that it will be constant for all the instances
created for that class.
• static variable need not be called from object.
• It is called by classname.static variable name
• Note: A static variable can never be defined inside a method i.e
it can never be a local variable.
Local variables
• Local variables are declared in method, constructor or block.
Local variables are initialized when method, constructor or
block start and will be destroyed once its end. Local variable
reside in stack. Access modifiers are not used for local variable.
float getDiscount(int price) {
float discount;
discount=price*(20/100);
return discount;
}
Arrays
• An array is a collection of similar data types. Array is a
container object that hold values of homogenous type. It is also
known as static data structure because size of an array must be
specified at the time of its declaration.
• An array can be either primitive or reference type. It gets
memory in heap area. Index of array starts from zero to size-1.
• It is always indexed. Index begins from 0.
• It is a collection of similar data types.
• It occupies a contiguous memory location.
Array – Program
class Test {
public static void main(String[] args) {
int[] arr = {10, 20, 30, 40};
for(int x : arr) {
System.out.println(x);
}
}
}
String Handling
• String is probably the most commonly used class in java library.
String class is encapsulated under java.lang package. In java,
every string that you create is actually an object of type String.
One important thing to notice about string object is that string
objects are immutable that means once a string object is
created it cannot be altered.
• An object whose state cannot be changed after it is created is
known as an Immutable object. String, Integer, Byte, Short,
Float, Double and all other wrapper classes objects are
immutable.
Thankyou..!!

Mais conteúdo relacionado

Mais procurados

Java 101 Intro to Java Programming
Java 101 Intro to Java ProgrammingJava 101 Intro to Java Programming
Java 101 Intro to Java Programmingagorolabs
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to javaSteve Fort
 
Introduction to java 101
Introduction to java 101Introduction to java 101
Introduction to java 101kankemwa Ishaku
 
Java Class 6 | Java Class 6 |Threads in Java| Applets | Swing GUI | JDBC | Ac...
Java Class 6 | Java Class 6 |Threads in Java| Applets | Swing GUI | JDBC | Ac...Java Class 6 | Java Class 6 |Threads in Java| Applets | Swing GUI | JDBC | Ac...
Java Class 6 | Java Class 6 |Threads in Java| Applets | Swing GUI | JDBC | Ac...Sagar Verma
 
Short notes of oop with java
Short notes of oop with javaShort notes of oop with java
Short notes of oop with javaMohamed Fathy
 
Functional Programming In Jdk8
Functional Programming In Jdk8 Functional Programming In Jdk8
Functional Programming In Jdk8 Bansilal Haudakari
 
Object oriented programming-with_java
Object oriented programming-with_javaObject oriented programming-with_java
Object oriented programming-with_javaHoang Nguyen
 
Core java lessons
Core java lessonsCore java lessons
Core java lessonsvivek shah
 
Learning core java
Learning core javaLearning core java
Learning core javaAbhay Bharti
 

Mais procurados (17)

Java 101 Intro to Java Programming
Java 101 Intro to Java ProgrammingJava 101 Intro to Java Programming
Java 101 Intro to Java Programming
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Introduction to java 101
Introduction to java 101Introduction to java 101
Introduction to java 101
 
Java ce241
Java ce241Java ce241
Java ce241
 
Core Java
Core JavaCore Java
Core Java
 
Core Java Tutorial
Core Java TutorialCore Java Tutorial
Core Java Tutorial
 
Java Class 6 | Java Class 6 |Threads in Java| Applets | Swing GUI | JDBC | Ac...
Java Class 6 | Java Class 6 |Threads in Java| Applets | Swing GUI | JDBC | Ac...Java Class 6 | Java Class 6 |Threads in Java| Applets | Swing GUI | JDBC | Ac...
Java Class 6 | Java Class 6 |Threads in Java| Applets | Swing GUI | JDBC | Ac...
 
Core Java
Core JavaCore Java
Core Java
 
Core java
Core javaCore java
Core java
 
Basics of Java
Basics of JavaBasics of Java
Basics of Java
 
Short notes of oop with java
Short notes of oop with javaShort notes of oop with java
Short notes of oop with java
 
Introduction To Java.
Introduction To Java.Introduction To Java.
Introduction To Java.
 
Functional Programming In Jdk8
Functional Programming In Jdk8 Functional Programming In Jdk8
Functional Programming In Jdk8
 
Object oriented programming-with_java
Object oriented programming-with_javaObject oriented programming-with_java
Object oriented programming-with_java
 
Core java lessons
Core java lessonsCore java lessons
Core java lessons
 
Java notes(OOP) jkuat IT esection
Java notes(OOP) jkuat IT esectionJava notes(OOP) jkuat IT esection
Java notes(OOP) jkuat IT esection
 
Learning core java
Learning core javaLearning core java
Learning core java
 

Semelhante a Java (20)

intro_java (1).pptx
intro_java (1).pptxintro_java (1).pptx
intro_java (1).pptx
 
Comp102 lec 3
Comp102   lec 3Comp102   lec 3
Comp102 lec 3
 
#_ varible function
#_ varible function #_ varible function
#_ varible function
 
Java (1).ppt seminar topics engineering
Java (1).ppt  seminar topics engineeringJava (1).ppt  seminar topics engineering
Java (1).ppt seminar topics engineering
 
oop unit1.pptx
oop unit1.pptxoop unit1.pptx
oop unit1.pptx
 
CS8392 OOP
CS8392 OOPCS8392 OOP
CS8392 OOP
 
ppt_on_java.pptx
ppt_on_java.pptxppt_on_java.pptx
ppt_on_java.pptx
 
1 java programming- introduction
1  java programming- introduction1  java programming- introduction
1 java programming- introduction
 
Java introduction
Java introductionJava introduction
Java introduction
 
Introduction to java (revised)
Introduction to java (revised)Introduction to java (revised)
Introduction to java (revised)
 
Java SpringMVC SpringBOOT (Divergent).ppt
Java SpringMVC SpringBOOT (Divergent).pptJava SpringMVC SpringBOOT (Divergent).ppt
Java SpringMVC SpringBOOT (Divergent).ppt
 
3. jvm
3. jvm3. jvm
3. jvm
 
Java programming basics
Java programming basicsJava programming basics
Java programming basics
 
Chapter 2 java
Chapter 2 javaChapter 2 java
Chapter 2 java
 
Module 1.pptx
Module 1.pptxModule 1.pptx
Module 1.pptx
 
1 Module 1 Introduction.pptx
1 Module 1 Introduction.pptx1 Module 1 Introduction.pptx
1 Module 1 Introduction.pptx
 
Complete PPT about the Java lokesh kept it
Complete PPT about the Java lokesh kept itComplete PPT about the Java lokesh kept it
Complete PPT about the Java lokesh kept it
 
Java introduction
Java introductionJava introduction
Java introduction
 
Java
JavaJava
Java
 
Basic online java course - Brainsmartlabs
Basic online java course  - BrainsmartlabsBasic online java course  - Brainsmartlabs
Basic online java course - Brainsmartlabs
 

Mais de Zeeshan Khan

Spring security4.x
Spring security4.xSpring security4.x
Spring security4.xZeeshan Khan
 
Micro services overview
Micro services overviewMicro services overview
Micro services overviewZeeshan Khan
 
XML / WEB SERVICES & RESTful Services
XML / WEB SERVICES & RESTful ServicesXML / WEB SERVICES & RESTful Services
XML / WEB SERVICES & RESTful ServicesZeeshan Khan
 
Collection framework (completenotes) zeeshan
Collection framework (completenotes) zeeshanCollection framework (completenotes) zeeshan
Collection framework (completenotes) zeeshanZeeshan Khan
 
JUnit with_mocking
JUnit with_mockingJUnit with_mocking
JUnit with_mockingZeeshan Khan
 
Introduction to BIG DATA
Introduction to BIG DATA Introduction to BIG DATA
Introduction to BIG DATA Zeeshan Khan
 
Android application development
Android application developmentAndroid application development
Android application developmentZeeshan Khan
 

Mais de Zeeshan Khan (12)

Apache kafka
Apache kafkaApache kafka
Apache kafka
 
Spring security4.x
Spring security4.xSpring security4.x
Spring security4.x
 
Micro services overview
Micro services overviewMicro services overview
Micro services overview
 
XML / WEB SERVICES & RESTful Services
XML / WEB SERVICES & RESTful ServicesXML / WEB SERVICES & RESTful Services
XML / WEB SERVICES & RESTful Services
 
Manual Testing
Manual TestingManual Testing
Manual Testing
 
Collection framework (completenotes) zeeshan
Collection framework (completenotes) zeeshanCollection framework (completenotes) zeeshan
Collection framework (completenotes) zeeshan
 
JUnit with_mocking
JUnit with_mockingJUnit with_mocking
JUnit with_mocking
 
OOPS in Java
OOPS in JavaOOPS in Java
OOPS in Java
 
Introduction to BIG DATA
Introduction to BIG DATA Introduction to BIG DATA
Introduction to BIG DATA
 
Big data
Big dataBig data
Big data
 
Android application development
Android application developmentAndroid application development
Android application development
 
Cyber crime
Cyber crimeCyber crime
Cyber crime
 

Último

call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdfPearlKirahMaeRagusta1
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024Mind IT Systems
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesVictorSzoltysek
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplatePresentation.STUDIO
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsArshad QA
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️Delhi Call girls
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...OnePlan Solutions
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...Health
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionOnePlan Solutions
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdfWave PLM
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech studentsHimanshiGarg82
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...kalichargn70th171
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfVishalKumarJha10
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxComplianceQuest1
 
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 GoalsJhone kinadey
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionSolGuruz
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfkalichargn70th171
 

Último (20)

call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Define the academic and professional writing..pdf
Define the academic and professional writing..pdfDefine the academic and professional writing..pdf
Define the academic and professional writing..pdf
 
10 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 202410 Trends Likely to Shape Enterprise Technology in 2024
10 Trends Likely to Shape Enterprise Technology in 2024
 
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM TechniquesAI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
AI Mastery 201: Elevating Your Workflow with Advanced LLM Techniques
 
AI & Machine Learning Presentation Template
AI & Machine Learning Presentation TemplateAI & Machine Learning Presentation Template
AI & Machine Learning Presentation Template
 
Software Quality Assurance Interview Questions
Software Quality Assurance Interview QuestionsSoftware Quality Assurance Interview Questions
Software Quality Assurance Interview Questions
 
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
call girls in Vaishali (Ghaziabad) 🔝 >༒8448380779 🔝 genuine Escort Service 🔝✔️✔️
 
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
Tech Tuesday-Harness the Power of Effective Resource Planning with OnePlan’s ...
 
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
+971565801893>>SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHAB...
 
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) SolutionIntroducing Microsoft’s new Enterprise Work Management (EWM) Solution
Introducing Microsoft’s new Enterprise Work Management (EWM) Solution
 
5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf5 Signs You Need a Fashion PLM Software.pdf
5 Signs You Need a Fashion PLM Software.pdf
 
8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students8257 interfacing 2 in microprocessor for btech students
8257 interfacing 2 in microprocessor for btech students
 
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
The Guide to Integrating Generative AI into Unified Continuous Testing Platfo...
 
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdfintroduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
introduction-to-automotive Andoid os-csimmonds-ndctechtown-2021.pdf
 
A Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docxA Secure and Reliable Document Management System is Essential.docx
A Secure and Reliable Document Management System is Essential.docx
 
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS LiveVip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
Vip Call Girls Noida ➡️ Delhi ➡️ 9999965857 No Advance 24HRS Live
 
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
 
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICECHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
CHEAP Call Girls in Pushp Vihar (-DELHI )🔝 9953056974🔝(=)/CALL GIRLS SERVICE
 
Diamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with PrecisionDiamond Application Development Crafting Solutions with Precision
Diamond Application Development Crafting Solutions with Precision
 
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdfLearn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
Learn the Fundamentals of XCUITest Framework_ A Beginner's Guide.pdf
 

Java

  • 2. Introduction to Java • Java is one of the world's most important and widely used computer languages, and it has held this distinction for many years. • As of 2018, Java is one of the most popular programming languages in use, particularly for client-server web applications, with a reported 9 million developers using and working on it.
  • 3. Creation Of Java • Java was developed by James Ghosling, Patrick Naughton, Mike Sheridan at Sun Microsystems Inc. in 1991. It took 18 months to develop the first working version. • The initial name was Oak but it was renamed to Java in 1995 as OAK was a registered trademark of another Tech company. • Java was initially launched as Java 1.0 and the current version of java is java 1.9.
  • 4. Application of Java • Java is widely used in every corner of world and of human life. Java is not only used in software's but is also widely used in designing hardware controlling software components. There are more than 930 million JRE downloads each year and 3 billion mobile phones run java. • Following are some other usage of Java : • Developing Desktop Applications • Web Applications like Linkedin.com, Snapdeal.com etc • Mobile Operating System like Android • Embedded Systems • Robotics and games etc.
  • 5. Setup Java Environment • For running Java programs in your system you will have to download and install JDK kit from here(current version is jdk 1.9).
  • 6. Java Features • Simple • Object Oriented • Platform-Independent • Robust • Secure • Multi-Threading • Architectural Neutral • Portable • High-Performance
  • 7. Introduction to JVM • Java virtual Machine(JVM) is a virtual Machine that provides runtime environment to execute java byte code. The JVM doesn't understand Java typo, that's why you compile your *.java files to obtain *.class files that contain the bytecodes understandable by the JVM. • JVM control execution of every Java program. It enables features such as automated exception handling, Garbage- collected heap.
  • 9. JVM Components • Class Loader : Class loader loads the Class for execution. • Method area : Stores pre-class structure as constant pool. • Heap : Heap is in which objects are allocated. • Stack : Local variables and partial results are store here. Each thread has a private JVM stack created when the thread is created. • Program register : Program register holds the address of JVM instruction currently being executed. • Native method stack : It contains all native used in application. • Executive Engine : Execution engine controls the execute of instructions contained in the methods of the classes. • Native Method Interface : Native method interface gives an interface between java code and native code during execution. • Native Method Libraries : Native Libraries consist of files required for the execution of native code.
  • 10. Differences between JDK JRE and JVM • JRE : The Java Runtime Environment (JRE) provides the libraries, the Java Virtual Machine, and other components to run applets and applications written in the Java programming language. JRE does not contain tools and utilities such as compilers or debuggers for developing applets and applications.
  • 11. Differences between JDK JRE and JVM • JDK : The JDK also called Java Development Kit is a superset of the JRE, and contains everything that is in the JRE, plus tools such as the compilers and debuggers necessary for developing applets and applications.
  • 12. First Java Program class Hello { public static void main(String[] args) { System.out.println ("Hello World program"); } }
  • 13. First Java Program-Explanation • class : class keyword is used to declare classes in Java • public : It is an access specifier. Public means this function is visible to all. • static : static is again a keyword used to make a function static. To execute a static function you do not have to create an Object of the class. The main() method here is called by JVM, without creating any object for class. • void : It is the return type, meaning this function will not return anything. • main : main() method is the most important method in a Java program. This is the method which is executed, hence all the logic must be inside the main() method. If a java class is not having a main() method, it causes compilation error. • String[] args : This represents an array whose type is String and name is args. We will discuss more about array in Java Array section. • System.out.println : This is used to print anything on the console like printf in C language
  • 14. Steps to Compile and Run your first Java program Step 1: Open a text editor and write the code as above. Step 2: Save the file as Hello.java Step 3: Open command prompt and go to the directory where you saved your first java program assuming it is saved in C: Step 4: Type javac Hello.java and press Return(Enter KEY) to compile your code. This command will call the Java Compiler asking it to compile the specified file. If there are no errors in the code the command prompt will take you to the next line. Step 5: Now type java Hello on command prompt to run your program. Step 6: You will be able to see Hello world program printed on your command prompt
  • 15. What happens at Runtime
  • 16. What happens at Runtime..contd • After writing your Java program, when you will try to compile it. Compiler will perform some compilation operation on your program. • Once it is compiled successfully byte code(.class file) is generated by the compiler. • After compiling when you will try to run the byte code(.class file), the following steps are performed at runtime:- • Class loader loads the java class. It is subsystem of JVM Java Virtual machine. • Byte Code verifier checks the code fragments for illegal codes that can violate access right to the object. • Interpreter reads the byte code stream and then executes the instructions, step by step.
  • 17. Data Types in Java • Java language has a rich implementation of data types. Data types specify size and the type of values that can be stored in an identifier. • In java, data types are classified into two catagories : • Primitive Data type • Non-Primitive Data type
  • 18. Primitive Data type • A primitive data type can be of eight types : • char • boolean • byte • short • int • long • float • double
  • 19. Integer group This group includes byte, short, int, long • byte : It is 1 byte(8-bits) integer data type. Value range from -128 to 127. Default value zero. example: byte b=10; • short : It is 2 bytes(16-bits) integer data type. Value range from -32768 to 32767. Default value zero. example: short s=11; • int : It is 4 bytes(32-bits) integer data type. Value range from -2147483648 to 2147483647. Default value zero. example: int i=10; • long : It is 8 bytes(64-bits) integer data type. Value range from - 9,223,372,036,854,775,808 to 9,223,372,036,854,775,807. Default value zero. example: long l=100012;
  • 20. Floating-Point Number This group includes float, double • float : It is 4 bytes(32-bits) float data type. Default value 0.0f. example: float ff=10.3f; • double : It is 8 bytes(64-bits) float data type. Default value 0.0d. example: double db=11.123;
  • 21. Characters • This group represent char, which represent symbols in a character set, like letters and numbers. • char : It is 2 bytes(16-bits) unsigned unicode character. Range 0 to 65,535. example: char c='a';
  • 22. Boolean • This group represent boolean, which is a special type for representing true/false values. They are defined constant of the language. • example: boolean b=true;
  • 23. Non-Primitive(Reference) Data type • A reference data type is used to refer to an object. A reference variable is declare to be of specific and that type can never be change. We will talk a lot more about reference data type later in Classes and Object lesson.
  • 24. Identifiers in Java • All Java components require names. Name used for classes, methods, interfaces and variables are called Identifier. Identifier must follow some rules. Here are the rules: • All identifiers must start with either a letter( a to z or A to Z ) or currency character($) or an underscore. • After the first character, an identifier can have any combination of characters. • A Java keyword cannot be used as an identifier. • Identifiers in Java are case sensitive, foo and Foo are two different identifiers.
  • 25. Variables • When we want to store any information, we store it in an address of the computer. Instead of remembering the complex address where we have stored our information, we name that address. The naming of an address is known as variable. Variable is the name of memory location. • Java Programming language defines mainly three kind of variables. • Instance variables • Static Variables • Local Variables
  • 26. Instance variables • Instance variables are variables that are declare inside a class but outside any method, constructor or block. Instance variable are also variable of object commonly known as field or property. They are referred as object variable. Each object has its own copy of each variable and thus, it doesn't effect the instance variable if one object changes the value of the variable. class Student { String name; int age; }
  • 27. Static variables • Static are class variables declared with static keyword. Static variables are initialized only once. Static variables are also used in declaring constant along with final keyword. class Student { String name; int age; static int instituteCode=1101; }
  • 28. Additional points on static variables: • static variable are also known as class variable. • static means to remain constant. • In Java, it means that it will be constant for all the instances created for that class. • static variable need not be called from object. • It is called by classname.static variable name • Note: A static variable can never be defined inside a method i.e it can never be a local variable.
  • 29. Local variables • Local variables are declared in method, constructor or block. Local variables are initialized when method, constructor or block start and will be destroyed once its end. Local variable reside in stack. Access modifiers are not used for local variable. float getDiscount(int price) { float discount; discount=price*(20/100); return discount; }
  • 30. Arrays • An array is a collection of similar data types. Array is a container object that hold values of homogenous type. It is also known as static data structure because size of an array must be specified at the time of its declaration. • An array can be either primitive or reference type. It gets memory in heap area. Index of array starts from zero to size-1. • It is always indexed. Index begins from 0. • It is a collection of similar data types. • It occupies a contiguous memory location.
  • 31. Array – Program class Test { public static void main(String[] args) { int[] arr = {10, 20, 30, 40}; for(int x : arr) { System.out.println(x); } } }
  • 32. String Handling • String is probably the most commonly used class in java library. String class is encapsulated under java.lang package. In java, every string that you create is actually an object of type String. One important thing to notice about string object is that string objects are immutable that means once a string object is created it cannot be altered. • An object whose state cannot be changed after it is created is known as an Immutable object. String, Integer, Byte, Short, Float, Double and all other wrapper classes objects are immutable.