SlideShare une entreprise Scribd logo
1  sur  6
Télécharger pour lire hors ligne
INTRODUCTION TO JAVA PROGRAMMING LANGUAGE
UNIT-1
[Feature to Java, Java Virtual Machine, Differences between C++ and Java, Part of Java, API Document,
Starting a Java Program. Important Classes, Formatting the Output]
FEATURE TO JAVA
1. Simple: Java is Easy to write and more readable and eye catching. Most of the concepts are
aimilar to C++, thus making Java learning simpler. It removed many confusing and/or
rarely-used features e.g., explicit pointers, operator overloading etc. Pointers and Operator
Overloading are not there in java but were an important part of C++. No need to remove
unreferenced objects because there is Automatic Garbage Collection in java.
2. Object-Oriented: Object-Oriented Programming Language (OOPs) is the methodology
which provide software development and maintenance by using object state, behavior , and
properties. Object Oriented Programming Language must have the following characteristics.
1. Encapsulation
2. Polymorphism
3. Inheritance
4. Abstraction
Java is pure OOP. Language. (while C++ is semi object oriented).
3. Secure: Java enable us to develop virus free, temper free system as it provides security
features like:
1. No explicit use of pointers
2. Every time when a user compiles the Java program, the Java compiler creates
a class file with Bytecode, which are tested by the JVM at the time of
program execution for viruses and other malicious files.
3. The concept of exception handling enables Java to capture a series of errors
that helps developers to get rid of risk of crashing the system.
4. Garbage Collection, etc.
4. Robust: Different security features of Java make this language robust. Java encourages
error-free programming by being strictly typed and performing run-time checks.
5. Platform Independent: Unlike other programming languages such as C, C++ etc which are
compiled into platform specific machines, Java is guaranteed to be write-once, run-
anywhere (WORA) language. On compilation Java program is compiled into bytecode. This
bytecode is platform independent and can be run on any machine, plus this bytecode format
also provide security. Any machine with Java Runtime Environment can run Java Programs.
Provided By Shipra Swati
INTRODUCTION TO JAVA PROGRAMMING LANGUAGE
6. Architecture-neutral: Java is independent of hardware e.g. size of primitive types is fixed.
In C programming, int data type occupies 2 bytes of memory for 32-bit architecture and 4
bytes of memory for 64-bit architecture. But in java, it occupies 4 bytes of memory for both
32 and 64 bit architectures.
7. Portable: The portability actually comes from architecture-neutrality. Java programs can
execute in any environment for which there is a Java run-time system (JVM), irrespective of
OS and hardware.
8. Multi-Threading: A thread is like a separate program, executing concurrently. Java
multithreading feature makes it possible to write program that can do many tasks
simultaneously. Benefit of multithreading is that it utilizes same memory and other
resources to execute multiple threads at the same time, like While typing, grammatical
errors are checked along.
9. High Performance: Java enables the creation of cross-platform programs with the help of
Byte code (Intermediate code). Most previos attempts for implementing cross-plaform
solutions compromise the performance parameter. But, Java bytecode was carefully
designed for easy and direct translation into native machine code by using Just-in-time
compiler for very high perfomance.
10. Distributed: Java is designed for the distributed environment of the internet because it
handles TCP/IP protocols. It also enables support for Remote Method Invocation (RMI),
which helps to invoke methods across a network.
JAVA VIRTUAL MACHINE
The overall development and execution infrastructure for a Java program is shown in following
figure. A program written in the Java programming language is compiled into a set of bytecodes.
Those bytecodes are then loaded and executed by a JVM. If the program makes calls to other Java
classes, the bytecodes for those classes will likewise be loaded, dynamically linked, and executed.
The Java Development Kit (JDK) provides software development environment for developing
Java applications. It includes JRE, java compiler and other required development tools.
Provided By Shipra Swati
INTRODUCTION TO JAVA PROGRAMMING LANGUAGE
JRE stands for “Java Runtime Environment” and may also be written as “Java RTE.” The Java
Runtime Environment provides the minimum requirements for executing a Java application; it
consists of the Java Virtual Machine (JVM), java interpreter and required libraries to run java
application.
JVM is short for Java Virtual Machine. JVM is an abstract computing machine, or virtual machine
or a machine within a machine – which acts like a real Java processor and provides a a
recommended environment to execute java bytecode. It needs the Java code library to run
applications. JVM only works with bytecode. Hence we need to compile our Java application
(.java) so that it can be converted to bytecode format (.class file).
JVM enabling Java bytecode to be executed as actions or operating system calls on any processor
regardless of the operating system. For example, establishing a socket connection from a
workstation to a remote machine involves an operating system call. Since different operating
systems handle sockets in different ways, the JVM translates the programming code so that the two
machines that may be on different platforms are able to connect.
JVM, JRE and JDK are platform dependent because configuration of each OS differs. But,
Java is platform independent.
Internal Architecture of JVM
Let's understand the internal architecture of JVM. It contains classloader, memory area, execution
engine etc. Diagrammatic representation is shown in next page.
1. Classloader: is a subsystem of JVM that is used to load class files.It loads, links. And
initializes the class file when it refers to a class for the first time at runtime, not compile
time.
2. JVM Memory Area: It is divided into 5 major components:
1. Method/Class Area – All the class level data will be stored here, including static
variables. There is only one method area per JVM, and it is a shared resource.
2. Heap: All the Objects and their corresponding instance variables and arrays will
be stored here. There is also one Heap Area per JVM. Since the Method and Heap
areas share memory for multiple threads, the data stored is not thread safe.
3. Stack: For every thread, a separate runtime stack will be created. For every
method call, one entry will be made in the stack memory which is called as Stack
Frame. All local variables will be created in the stack memory. The stack area is
thread safe since it is not a shared resource.
4. PC Registers: Each thread will have separate PC Registers, to hold the address of
current executing instruction. Once the instruction is executed the PC register will
be updated with the next instruction.
5. Native Method stacks: Native Method Stack holds native method information used
in the application. For every thread, a separate native method stack will be created.
Provided By Shipra Swati
INTRODUCTION TO JAVA PROGRAMMING LANGUAGE
3. Execution Engine: The bytecode which is assigned to the JVM Memory Area will be
executed by the Execution Engine. The Execution Engine reads the bytecode and executes
it piece by piece. It contains:
1. Interpreter– The interpreter interprets the bytecode faster, but executes slowly. The
disadvantage of the interpreter is that when one method is called multiple times,
every time a new interpretation is required.
2. JIT Compiler– The JIT Compiler neutralizes the disadvantage of the interpreter by
improving the performance. JIT compiles parts of the byte code that have similar
functionality at the same time, and hence reduces the amount of time needed for
compilation.Here the term “compiler” refers to a translator from the instruction set
of a Java virtual machine (JVM) to the instruction set of a specific CPU.
3. Garbage Collector– It Collects and removes unreferenced objects. Garbage
Collection can be triggered by calling "System.gc()", but the execution is not
guaranteed.
4. Java Native Method Interface: It will be interacting with the Native Method Libraries.
5. Native Method Libraries: It is a collection of the Native Libraries which is required for
the Execution Engine.
Provided By Shipra Swati
INTRODUCTION TO JAVA PROGRAMMING LANGUAGE
DIFFERENCES BETWEEN C++ AND JAVA
C++ JAVA
1.
C++ was developed by Bjarne Stroustrup.
Development began in 1979.
Java was developed by James Gosling
and his team. Development began in
1991.
2. C++ is a compiled language. Java is both compiled and interpreted.
3.
C++ programs are platform dependent. They need
to be compiled for a particular platform.
Java programs are platform independent.
Java programs are written for Java
Virtual Machine (JVM) and wherever a
JVM is installed, Java program will run
without needing recompilation.
4.
C++ does support operator overloading. Function
overloading is also available.
Java does not support operator
overloading. However, function
overloading is possible.
5. C++ fully supports pointers.
Java supports pointer internally. But you
can't write the pointer program in java.
6. C++ supports structures and unions.
Java does not support structures and
unions.
7. C++ does not have built-in support for threads. Java fully supports threads.
8.
C++ supports manual object management through
new and deletekeywords.
Java relies on automatic garbage
collection. It does not support destructors
the way C++ does.
9.
C++ supports goto statement (however the use of
goto is discouraged as not considered a good
practice)
Java does not support goto statement
(although goto is a reserved keyword in
Java)
10. C++ supports multiple inheritance.
Java does not really support multiple
inheritance. But similar results can be
achieved through the use of interfaces.
11.
C++ provides support both for call by value and call
by reference.
Java supports only call by value.
12.
C++ provides virtual keyword to support function
overriding.
Java does not support virtual keyword.
All the non-static Java functions are by
default virtual in nature, and therefore,
can be overridden.
13. C++ is mainly used for system programming.
Java is mainly used for application
programming. It is widely used in
window, web-based, enterprise and
mobile applications.
Provided By Shipra Swati
INTRODUCTION TO JAVA PROGRAMMING LANGUAGE
API Document
An application programming interface (API), in the context of Java, is a collection of prewritten
packages, classes, and interfaces with their respective methods, fields and constructors. In Java,
most basic programming tasks are performed by the API’s classes and packages, which are helpful
in minimizing the number of lines written within pieces of code.
The API is a library of available Java classes, packages and interfaces. The three API types are as
follows:
• Official Java core API, which is bundled with the JDK download
• Optional official Java APIs, which may be downloaded if needed
• Unofficial APIs, which are third-party APIs that may be downloaded from source websites
The official API includes packages, e.g., applet packages, graphics and GUI swing packages,
input/output (IO) packages and Abstract Windows Toolkit (AWT), among others.
Important Classes
• The System (java.lang.System) class contains several useful class fields and methods for
standard input, standard output, and error output streams. It cannot be instantiated.
• The java.lang.String class provides a lot of methods to work on string. By the help of these
methods, we can perform operations on string such as trimming, concatenating, converting,
comparing, replacing strings etc.
• Scanner is a class in java.util package used for obtaining the input of the primitive types
like int, double etc. and strings. It is the easiest way to read input in a Java program.
• The Object class (java.lang.Object) is the parent class of all the classes in java by default. In
other words, it is the topmost class of java.
Provided By Shipra Swati

Contenu connexe

Tendances

INTRODUCTION TO JAVA APPLICATION
INTRODUCTION TO JAVA APPLICATIONINTRODUCTION TO JAVA APPLICATION
INTRODUCTION TO JAVA APPLICATIONAjit Yadav
 
Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...Mr. Akaash
 
Chapter 1 introduction to java technology
Chapter 1 introduction to java technologyChapter 1 introduction to java technology
Chapter 1 introduction to java technologysshhzap
 
1 java programming- introduction
1  java programming- introduction1  java programming- introduction
1 java programming- introductionjyoti_lakhani
 
Presentation on Core java
Presentation on Core javaPresentation on Core java
Presentation on Core javamahir jain
 
Learn Java with Dr. Rifat Shahriyar
Learn Java with Dr. Rifat ShahriyarLearn Java with Dr. Rifat Shahriyar
Learn Java with Dr. Rifat ShahriyarAbir Mohammad
 
Introduction to java
Introduction to java Introduction to java
Introduction to java Sandeep Rawat
 
1 Introduction To Java Technology
1 Introduction To Java Technology 1 Introduction To Java Technology
1 Introduction To Java Technology dM Technologies
 
Important features of java
Important features of javaImportant features of java
Important features of javaAL- AMIN
 
Grade 8: Introduction To Java
Grade 8: Introduction To JavaGrade 8: Introduction To Java
Grade 8: Introduction To Javanandanrocker
 

Tendances (20)

INTRODUCTION TO JAVA APPLICATION
INTRODUCTION TO JAVA APPLICATIONINTRODUCTION TO JAVA APPLICATION
INTRODUCTION TO JAVA APPLICATION
 
Bn1005 demo ppt core java
Bn1005 demo ppt core javaBn1005 demo ppt core java
Bn1005 demo ppt core java
 
Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...
 
Introduction to java technology
Introduction to java technologyIntroduction to java technology
Introduction to java technology
 
Chapter 1 introduction to java technology
Chapter 1 introduction to java technologyChapter 1 introduction to java technology
Chapter 1 introduction to java technology
 
1 java programming- introduction
1  java programming- introduction1  java programming- introduction
1 java programming- introduction
 
Presentation on Core java
Presentation on Core javaPresentation on Core java
Presentation on Core java
 
Learn Java Part 1
Learn Java Part 1Learn Java Part 1
Learn Java Part 1
 
Introduction To Java.
Introduction To Java.Introduction To Java.
Introduction To Java.
 
Learn Java with Dr. Rifat Shahriyar
Learn Java with Dr. Rifat ShahriyarLearn Java with Dr. Rifat Shahriyar
Learn Java with Dr. Rifat Shahriyar
 
Introducing Java 7
Introducing Java 7Introducing Java 7
Introducing Java 7
 
Introduction to JAVA
Introduction to JAVAIntroduction to JAVA
Introduction to JAVA
 
Java Programming
Java ProgrammingJava Programming
Java Programming
 
Introduction to java
Introduction to java Introduction to java
Introduction to java
 
Java features
Java featuresJava features
Java features
 
Java Introduction
Java IntroductionJava Introduction
Java Introduction
 
1 Introduction To Java Technology
1 Introduction To Java Technology 1 Introduction To Java Technology
1 Introduction To Java Technology
 
Java
JavaJava
Java
 
Important features of java
Important features of javaImportant features of java
Important features of java
 
Grade 8: Introduction To Java
Grade 8: Introduction To JavaGrade 8: Introduction To Java
Grade 8: Introduction To Java
 

Similaire à Java unit 1

Notes of java first unit
Notes of java first unitNotes of java first unit
Notes of java first unitgowher172236
 
Sybsc cs sem 3 core java
Sybsc cs sem 3 core javaSybsc cs sem 3 core java
Sybsc cs sem 3 core javaWE-IT TUTORIALS
 
Ijaprr vol1-2-13-60-64tejinder
Ijaprr vol1-2-13-60-64tejinderIjaprr vol1-2-13-60-64tejinder
Ijaprr vol1-2-13-60-64tejinderijaprr_editor
 
Java Introduction | PDF
Java Introduction |  PDFJava Introduction |  PDF
Java Introduction | PDFGeekster
 
JAVA_Day1_BasicIntroduction.pptx
JAVA_Day1_BasicIntroduction.pptxJAVA_Day1_BasicIntroduction.pptx
JAVA_Day1_BasicIntroduction.pptxMurugesh33
 
JAVAPart1_BasicIntroduction.pptx
JAVAPart1_BasicIntroduction.pptxJAVAPart1_BasicIntroduction.pptx
JAVAPart1_BasicIntroduction.pptxMurugesh33
 
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
 
Presentación rs232 java
Presentación rs232 javaPresentación rs232 java
Presentación rs232 javaJohn Rojas
 
J2ee strutswithhibernate-140121221332-phpapp01
J2ee strutswithhibernate-140121221332-phpapp01J2ee strutswithhibernate-140121221332-phpapp01
J2ee strutswithhibernate-140121221332-phpapp01Jay Palit
 
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 Lecture 1
Java Lecture 1Java Lecture 1
Java Lecture 1Qualys
 
Advanced java training in bangalore
Advanced java training in bangaloreAdvanced java training in bangalore
Advanced java training in bangaloresiyaram ray
 
Advanced java-training-in-bangalore
Advanced java-training-in-bangaloreAdvanced java-training-in-bangalore
Advanced java-training-in-bangaloresiyaram ray
 

Similaire à Java unit 1 (20)

Java ms harsha
Java ms harshaJava ms harsha
Java ms harsha
 
Unit1 JAVA.pptx
Unit1 JAVA.pptxUnit1 JAVA.pptx
Unit1 JAVA.pptx
 
Notes of java first unit
Notes of java first unitNotes of java first unit
Notes of java first unit
 
Sybsc cs sem 3 core java
Sybsc cs sem 3 core javaSybsc cs sem 3 core java
Sybsc cs sem 3 core java
 
Java chapter 1
Java   chapter 1Java   chapter 1
Java chapter 1
 
Unit-IV_Introduction to Java.pdf
Unit-IV_Introduction to Java.pdfUnit-IV_Introduction to Java.pdf
Unit-IV_Introduction to Java.pdf
 
Ijaprr vol1-2-13-60-64tejinder
Ijaprr vol1-2-13-60-64tejinderIjaprr vol1-2-13-60-64tejinder
Ijaprr vol1-2-13-60-64tejinder
 
Java lab lecture 1
Java  lab  lecture 1Java  lab  lecture 1
Java lab lecture 1
 
Java Introduction | PDF
Java Introduction |  PDFJava Introduction |  PDF
Java Introduction | PDF
 
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
 
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
 
Presentación rs232 java
Presentación rs232 javaPresentación rs232 java
Presentación rs232 java
 
J2ee strutswithhibernate-140121221332-phpapp01
J2ee strutswithhibernate-140121221332-phpapp01J2ee strutswithhibernate-140121221332-phpapp01
J2ee strutswithhibernate-140121221332-phpapp01
 
Java & J2EE Struts with Hibernate Framework
Java & J2EE Struts with Hibernate FrameworkJava & J2EE Struts with Hibernate Framework
Java & J2EE Struts with Hibernate Framework
 
Java Lecture 1
Java Lecture 1Java Lecture 1
Java Lecture 1
 
Advanced java training in bangalore
Advanced java training in bangaloreAdvanced java training in bangalore
Advanced java training in bangalore
 
Advanced java-training-in-bangalore
Advanced java-training-in-bangaloreAdvanced java-training-in-bangalore
Advanced java-training-in-bangalore
 
Java lab zero lecture
Java  lab  zero lectureJava  lab  zero lecture
Java lab zero lecture
 
Basic Java I
Basic Java IBasic Java I
Basic Java I
 

Plus de Shipra Swati

Operating System-Process Scheduling
Operating System-Process SchedulingOperating System-Process Scheduling
Operating System-Process SchedulingShipra Swati
 
Operating System-Concepts of Process
Operating System-Concepts of ProcessOperating System-Concepts of Process
Operating System-Concepts of ProcessShipra Swati
 
Operating System-Introduction
Operating System-IntroductionOperating System-Introduction
Operating System-IntroductionShipra Swati
 
Fundamental of Information Technology - UNIT 8
Fundamental of Information Technology - UNIT 8Fundamental of Information Technology - UNIT 8
Fundamental of Information Technology - UNIT 8Shipra Swati
 
Fundamental of Information Technology - UNIT 7
Fundamental of Information Technology - UNIT 7Fundamental of Information Technology - UNIT 7
Fundamental of Information Technology - UNIT 7Shipra Swati
 
Fundamental of Information Technology - UNIT 6
Fundamental of Information Technology - UNIT 6Fundamental of Information Technology - UNIT 6
Fundamental of Information Technology - UNIT 6Shipra Swati
 
Fundamental of Information Technology
Fundamental of Information TechnologyFundamental of Information Technology
Fundamental of Information TechnologyShipra Swati
 
Process Synchronization
Process SynchronizationProcess Synchronization
Process SynchronizationShipra Swati
 

Plus de Shipra Swati (20)

Operating System-Process Scheduling
Operating System-Process SchedulingOperating System-Process Scheduling
Operating System-Process Scheduling
 
Operating System-Concepts of Process
Operating System-Concepts of ProcessOperating System-Concepts of Process
Operating System-Concepts of Process
 
Operating System-Introduction
Operating System-IntroductionOperating System-Introduction
Operating System-Introduction
 
Java unit 11
Java unit 11Java unit 11
Java unit 11
 
Java unit 14
Java unit 14Java unit 14
Java unit 14
 
Java unit 12
Java unit 12Java unit 12
Java unit 12
 
Java unit 7
Java unit 7Java unit 7
Java unit 7
 
Java unit 3
Java unit 3Java unit 3
Java unit 3
 
Java unit 2
Java unit 2Java unit 2
Java unit 2
 
OOPS_Unit_1
OOPS_Unit_1OOPS_Unit_1
OOPS_Unit_1
 
Ai lab manual
Ai lab manualAi lab manual
Ai lab manual
 
Fundamental of Information Technology - UNIT 8
Fundamental of Information Technology - UNIT 8Fundamental of Information Technology - UNIT 8
Fundamental of Information Technology - UNIT 8
 
Fundamental of Information Technology - UNIT 7
Fundamental of Information Technology - UNIT 7Fundamental of Information Technology - UNIT 7
Fundamental of Information Technology - UNIT 7
 
Fundamental of Information Technology - UNIT 6
Fundamental of Information Technology - UNIT 6Fundamental of Information Technology - UNIT 6
Fundamental of Information Technology - UNIT 6
 
Fundamental of Information Technology
Fundamental of Information TechnologyFundamental of Information Technology
Fundamental of Information Technology
 
Disk Management
Disk ManagementDisk Management
Disk Management
 
File Systems
File SystemsFile Systems
File Systems
 
Memory Management
Memory ManagementMemory Management
Memory Management
 
Deadlocks
DeadlocksDeadlocks
Deadlocks
 
Process Synchronization
Process SynchronizationProcess Synchronization
Process Synchronization
 

Dernier

Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxAsutosh Ranjan
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escortsranjana rawat
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Christo Ananth
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls in Nagpur High Profile
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...Call Girls in Nagpur High Profile
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSRajkumarAkumalla
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations120cr0395
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINESIVASHANKAR N
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsCall Girls in Nagpur High Profile
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college projectTonystark477637
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...ranjana rawat
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).pptssuser5c9d4b1
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...roncy bisnoi
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxpurnimasatapathy1234
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Christo Ananth
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)Suman Mia
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordAsst.prof M.Gokilavani
 

Dernier (20)

Coefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptxCoefficient of Thermal Expansion and their Importance.pptx
Coefficient of Thermal Expansion and their Importance.pptx
 
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Isha Call 7001035870 Meet With Nagpur Escorts
 
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
Call for Papers - Educational Administration: Theory and Practice, E-ISSN: 21...
 
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service NashikCall Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
Call Girls Service Nashik Vaishnavi 7001305949 Independent Escort Service Nashik
 
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...Booking open Available Pune Call Girls Koregaon Park  6297143586 Call Hot Ind...
Booking open Available Pune Call Girls Koregaon Park 6297143586 Call Hot Ind...
 
Roadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and RoutesRoadmap to Membership of RICS - Pathways and Routes
Roadmap to Membership of RICS - Pathways and Routes
 
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICSHARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
HARDNESS, FRACTURE TOUGHNESS AND STRENGTH OF CERAMICS
 
Extrusion Processes and Their Limitations
Extrusion Processes and Their LimitationsExtrusion Processes and Their Limitations
Extrusion Processes and Their Limitations
 
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINEMANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
MANUFACTURING PROCESS-II UNIT-2 LATHE MACHINE
 
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur EscortsHigh Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
High Profile Call Girls Nagpur Meera Call 7001035870 Meet With Nagpur Escorts
 
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINEDJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
DJARUM4D - SLOT GACOR ONLINE | SLOT DEMO ONLINE
 
result management system report for college project
result management system report for college projectresult management system report for college project
result management system report for college project
 
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
(ANVI) Koregaon Park Call Girls Just Call 7001035870 [ Cash on Delivery ] Pun...
 
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
247267395-1-Symmetric-and-distributed-shared-memory-architectures-ppt (1).ppt
 
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
Call Girls Pimpri Chinchwad Call Me 7737669865 Budget Friendly No Advance Boo...
 
Microscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptxMicroscopic Analysis of Ceramic Materials.pptx
Microscopic Analysis of Ceramic Materials.pptx
 
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
Call for Papers - African Journal of Biological Sciences, E-ISSN: 2663-2187, ...
 
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)Software Development Life Cycle By  Team Orange (Dept. of Pharmacy)
Software Development Life Cycle By Team Orange (Dept. of Pharmacy)
 
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete RecordCCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
CCS335 _ Neural Networks and Deep Learning Laboratory_Lab Complete Record
 
Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024Water Industry Process Automation & Control Monthly - April 2024
Water Industry Process Automation & Control Monthly - April 2024
 

Java unit 1

  • 1. INTRODUCTION TO JAVA PROGRAMMING LANGUAGE UNIT-1 [Feature to Java, Java Virtual Machine, Differences between C++ and Java, Part of Java, API Document, Starting a Java Program. Important Classes, Formatting the Output] FEATURE TO JAVA 1. Simple: Java is Easy to write and more readable and eye catching. Most of the concepts are aimilar to C++, thus making Java learning simpler. It removed many confusing and/or rarely-used features e.g., explicit pointers, operator overloading etc. Pointers and Operator Overloading are not there in java but were an important part of C++. No need to remove unreferenced objects because there is Automatic Garbage Collection in java. 2. Object-Oriented: Object-Oriented Programming Language (OOPs) is the methodology which provide software development and maintenance by using object state, behavior , and properties. Object Oriented Programming Language must have the following characteristics. 1. Encapsulation 2. Polymorphism 3. Inheritance 4. Abstraction Java is pure OOP. Language. (while C++ is semi object oriented). 3. Secure: Java enable us to develop virus free, temper free system as it provides security features like: 1. No explicit use of pointers 2. Every time when a user compiles the Java program, the Java compiler creates a class file with Bytecode, which are tested by the JVM at the time of program execution for viruses and other malicious files. 3. The concept of exception handling enables Java to capture a series of errors that helps developers to get rid of risk of crashing the system. 4. Garbage Collection, etc. 4. Robust: Different security features of Java make this language robust. Java encourages error-free programming by being strictly typed and performing run-time checks. 5. Platform Independent: Unlike other programming languages such as C, C++ etc which are compiled into platform specific machines, Java is guaranteed to be write-once, run- anywhere (WORA) language. On compilation Java program is compiled into bytecode. This bytecode is platform independent and can be run on any machine, plus this bytecode format also provide security. Any machine with Java Runtime Environment can run Java Programs. Provided By Shipra Swati
  • 2. INTRODUCTION TO JAVA PROGRAMMING LANGUAGE 6. Architecture-neutral: Java is independent of hardware e.g. size of primitive types is fixed. In C programming, int data type occupies 2 bytes of memory for 32-bit architecture and 4 bytes of memory for 64-bit architecture. But in java, it occupies 4 bytes of memory for both 32 and 64 bit architectures. 7. Portable: The portability actually comes from architecture-neutrality. Java programs can execute in any environment for which there is a Java run-time system (JVM), irrespective of OS and hardware. 8. Multi-Threading: A thread is like a separate program, executing concurrently. Java multithreading feature makes it possible to write program that can do many tasks simultaneously. Benefit of multithreading is that it utilizes same memory and other resources to execute multiple threads at the same time, like While typing, grammatical errors are checked along. 9. High Performance: Java enables the creation of cross-platform programs with the help of Byte code (Intermediate code). Most previos attempts for implementing cross-plaform solutions compromise the performance parameter. But, Java bytecode was carefully designed for easy and direct translation into native machine code by using Just-in-time compiler for very high perfomance. 10. Distributed: Java is designed for the distributed environment of the internet because it handles TCP/IP protocols. It also enables support for Remote Method Invocation (RMI), which helps to invoke methods across a network. JAVA VIRTUAL MACHINE The overall development and execution infrastructure for a Java program is shown in following figure. A program written in the Java programming language is compiled into a set of bytecodes. Those bytecodes are then loaded and executed by a JVM. If the program makes calls to other Java classes, the bytecodes for those classes will likewise be loaded, dynamically linked, and executed. The Java Development Kit (JDK) provides software development environment for developing Java applications. It includes JRE, java compiler and other required development tools. Provided By Shipra Swati
  • 3. INTRODUCTION TO JAVA PROGRAMMING LANGUAGE JRE stands for “Java Runtime Environment” and may also be written as “Java RTE.” The Java Runtime Environment provides the minimum requirements for executing a Java application; it consists of the Java Virtual Machine (JVM), java interpreter and required libraries to run java application. JVM is short for Java Virtual Machine. JVM is an abstract computing machine, or virtual machine or a machine within a machine – which acts like a real Java processor and provides a a recommended environment to execute java bytecode. It needs the Java code library to run applications. JVM only works with bytecode. Hence we need to compile our Java application (.java) so that it can be converted to bytecode format (.class file). JVM enabling Java bytecode to be executed as actions or operating system calls on any processor regardless of the operating system. For example, establishing a socket connection from a workstation to a remote machine involves an operating system call. Since different operating systems handle sockets in different ways, the JVM translates the programming code so that the two machines that may be on different platforms are able to connect. JVM, JRE and JDK are platform dependent because configuration of each OS differs. But, Java is platform independent. Internal Architecture of JVM Let's understand the internal architecture of JVM. It contains classloader, memory area, execution engine etc. Diagrammatic representation is shown in next page. 1. Classloader: is a subsystem of JVM that is used to load class files.It loads, links. And initializes the class file when it refers to a class for the first time at runtime, not compile time. 2. JVM Memory Area: It is divided into 5 major components: 1. Method/Class Area – All the class level data will be stored here, including static variables. There is only one method area per JVM, and it is a shared resource. 2. Heap: All the Objects and their corresponding instance variables and arrays will be stored here. There is also one Heap Area per JVM. Since the Method and Heap areas share memory for multiple threads, the data stored is not thread safe. 3. Stack: For every thread, a separate runtime stack will be created. For every method call, one entry will be made in the stack memory which is called as Stack Frame. All local variables will be created in the stack memory. The stack area is thread safe since it is not a shared resource. 4. PC Registers: Each thread will have separate PC Registers, to hold the address of current executing instruction. Once the instruction is executed the PC register will be updated with the next instruction. 5. Native Method stacks: Native Method Stack holds native method information used in the application. For every thread, a separate native method stack will be created. Provided By Shipra Swati
  • 4. INTRODUCTION TO JAVA PROGRAMMING LANGUAGE 3. Execution Engine: The bytecode which is assigned to the JVM Memory Area will be executed by the Execution Engine. The Execution Engine reads the bytecode and executes it piece by piece. It contains: 1. Interpreter– The interpreter interprets the bytecode faster, but executes slowly. The disadvantage of the interpreter is that when one method is called multiple times, every time a new interpretation is required. 2. JIT Compiler– The JIT Compiler neutralizes the disadvantage of the interpreter by improving the performance. JIT compiles parts of the byte code that have similar functionality at the same time, and hence reduces the amount of time needed for compilation.Here the term “compiler” refers to a translator from the instruction set of a Java virtual machine (JVM) to the instruction set of a specific CPU. 3. Garbage Collector– It Collects and removes unreferenced objects. Garbage Collection can be triggered by calling "System.gc()", but the execution is not guaranteed. 4. Java Native Method Interface: It will be interacting with the Native Method Libraries. 5. Native Method Libraries: It is a collection of the Native Libraries which is required for the Execution Engine. Provided By Shipra Swati
  • 5. INTRODUCTION TO JAVA PROGRAMMING LANGUAGE DIFFERENCES BETWEEN C++ AND JAVA C++ JAVA 1. C++ was developed by Bjarne Stroustrup. Development began in 1979. Java was developed by James Gosling and his team. Development began in 1991. 2. C++ is a compiled language. Java is both compiled and interpreted. 3. C++ programs are platform dependent. They need to be compiled for a particular platform. Java programs are platform independent. Java programs are written for Java Virtual Machine (JVM) and wherever a JVM is installed, Java program will run without needing recompilation. 4. C++ does support operator overloading. Function overloading is also available. Java does not support operator overloading. However, function overloading is possible. 5. C++ fully supports pointers. Java supports pointer internally. But you can't write the pointer program in java. 6. C++ supports structures and unions. Java does not support structures and unions. 7. C++ does not have built-in support for threads. Java fully supports threads. 8. C++ supports manual object management through new and deletekeywords. Java relies on automatic garbage collection. It does not support destructors the way C++ does. 9. C++ supports goto statement (however the use of goto is discouraged as not considered a good practice) Java does not support goto statement (although goto is a reserved keyword in Java) 10. C++ supports multiple inheritance. Java does not really support multiple inheritance. But similar results can be achieved through the use of interfaces. 11. C++ provides support both for call by value and call by reference. Java supports only call by value. 12. C++ provides virtual keyword to support function overriding. Java does not support virtual keyword. All the non-static Java functions are by default virtual in nature, and therefore, can be overridden. 13. C++ is mainly used for system programming. Java is mainly used for application programming. It is widely used in window, web-based, enterprise and mobile applications. Provided By Shipra Swati
  • 6. INTRODUCTION TO JAVA PROGRAMMING LANGUAGE API Document An application programming interface (API), in the context of Java, is a collection of prewritten packages, classes, and interfaces with their respective methods, fields and constructors. In Java, most basic programming tasks are performed by the API’s classes and packages, which are helpful in minimizing the number of lines written within pieces of code. The API is a library of available Java classes, packages and interfaces. The three API types are as follows: • Official Java core API, which is bundled with the JDK download • Optional official Java APIs, which may be downloaded if needed • Unofficial APIs, which are third-party APIs that may be downloaded from source websites The official API includes packages, e.g., applet packages, graphics and GUI swing packages, input/output (IO) packages and Abstract Windows Toolkit (AWT), among others. Important Classes • The System (java.lang.System) class contains several useful class fields and methods for standard input, standard output, and error output streams. It cannot be instantiated. • The java.lang.String class provides a lot of methods to work on string. By the help of these methods, we can perform operations on string such as trimming, concatenating, converting, comparing, replacing strings etc. • Scanner is a class in java.util package used for obtaining the input of the primitive types like int, double etc. and strings. It is the easiest way to read input in a Java program. • The Object class (java.lang.Object) is the parent class of all the classes in java by default. In other words, it is the topmost class of java. Provided By Shipra Swati