SlideShare a Scribd company logo
1 of 48
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:1
CORE-JAVA
By SimiBy Simi
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:2
First, a bit of background…
 11stst
Generation – machine languageGeneration – machine language
 (raw machine code – lots of binary 0100101010001000111)
 22ndnd
Generation – assembly languageGeneration – assembly language
 (mnemonic representation – short series of chars to represent binary)
 33rdrd
Generation – structured programmingGeneration – structured programming
 (e.g. Pascal, C, C++, Java)
 44thth
Generation – application specificGeneration – application specific
 (SQL, Mathematica, RPG II, PostScript)
 55thth
Generation – combining artificial intelligenceGeneration – combining artificial intelligence
 (best not mentioned…)
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:3
Towards Structured Programming
 As computer programs become largerAs computer programs become larger
and more complex, more errors areand more complex, more errors are
introduced.introduced.
 It has been estimated that there are 15It has been estimated that there are 15
bugs in every 1000 lines of commercialbugs in every 1000 lines of commercial
code.code.
 Windows 2000 had 40 million lines ofWindows 2000 had 40 million lines of
code!code!
 Most bugs are caused by poor memoryMost bugs are caused by poor memory
management.management.
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:4
Contd:
 Clearly there is a need for a structuredClearly there is a need for a structured
programming language that helps inprogramming language that helps in
reducing the number of errors andreducing the number of errors and
speeds development for programmingspeeds development for programming
teams.teams.
 CC →→ C++C++ →→ JavaJava
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:5
Contd:
 Functional ProgrammingFunctional Programming →→ ObjectObject
OrientationOrientation
““C makes it easy to shoot yourself in theC makes it easy to shoot yourself in the
foot; C++ makes it harder, but when itfoot; C++ makes it harder, but when it
happens you tend to take off the wholehappens you tend to take off the whole
leg!”leg!”
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:6
What is Object-Oriented code?
 Procedural coding is just a list of instructions.Procedural coding is just a list of instructions.
 Object-oriented code has a lot of similarity withObject-oriented code has a lot of similarity with
code from other procedural languages.code from other procedural languages.
 Basically, a lot of the ‘words’ are the same but theBasically, a lot of the ‘words’ are the same but the
way the words are put together (the structure) isway the words are put together (the structure) is
different.different.
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:7
Contd:
 Object-oriented coding does also contain lists ofObject-oriented coding does also contain lists of
instructions but these lists are bound to specificinstructions but these lists are bound to specific
objects.objects.
 What an object actually represents is up to theWhat an object actually represents is up to the
programmer.programmer.
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:8
Simple Example
 AA car is an object (in the real world) and in ourcar is an object (in the real world) and in our
program we can make a software object toprogram we can make a software object to
represent it.represent it.
 Fundamentally, an object contains data andFundamentally, an object contains data and
methods which can act on that data.methods which can act on that data.
 The data we might want to have in our ‘software’The data we might want to have in our ‘software’
car could be things like: body colour, engine size,car could be things like: body colour, engine size,
current speed, whether it has electric windows etc.current speed, whether it has electric windows etc.
Basically it’s up to you.Basically it’s up to you.
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:9
Simple Example
 The methods we might want our ‘car’ to haveThe methods we might want our ‘car’ to have
could be things like: accelerate, brake, respraycould be things like: accelerate, brake, respray
body, open passenger window etc. Again, it’s up tobody, open passenger window etc. Again, it’s up to
you.you.
 Whatever you need your software car to modelWhatever you need your software car to model
from the real world object must be present in yourfrom the real world object must be present in your
code.code.
 The OO syntax enables you to do this intuitively.The OO syntax enables you to do this intuitively.
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:10
What technology does it replace?
 Procedural programming (C, Visual Basic, FortranProcedural programming (C, Visual Basic, Fortran
etc.)etc.)
 In procedural programming, functions were theIn procedural programming, functions were the
most important part of the software.most important part of the software.
 Where and how the data was stored was secondaryWhere and how the data was stored was secondary
(at best).(at best).
 Procedural code is process-oriented, OO code isProcedural code is process-oriented, OO code is
data-oriented.data-oriented.
 In procedural programming, if your code is in errorIn procedural programming, if your code is in error
then it is relatively easy to fix but incorrect datathen it is relatively easy to fix but incorrect data
may bemay be impossibleimpossible to fix!to fix!
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:11
Java (why use it?)
Advantages over C & C++Advantages over C & C++
 WORA - Write Once, Run Anywhere (portable).WORA - Write Once, Run Anywhere (portable).
 Security (can run “untrusted” code safely).Security (can run “untrusted” code safely).
 Robust memory management (opaque references,Robust memory management (opaque references,
automatic garbage collection)automatic garbage collection)
 Network-centric programming.Network-centric programming.
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:12
Java (why use it?)
 Multi-threaded (multiple simultaneous tasks).Multi-threaded (multiple simultaneous tasks).
 Dynamic & extensible.Dynamic & extensible.
 Classes stored in separate files
 Loaded only when needed
 Can dynamically extend itself to expand its
functionality (even over a network and the
Internet!)
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:13
How does it help?
 Large projects can be broken down into modulesLarge projects can be broken down into modules
more easily.more easily.
 Aids understanding.Aids understanding.
 Groupwork is easier.Groupwork is easier.
 Less chance of data corruption.Less chance of data corruption.
 Aids reusability/extensibility.Aids reusability/extensibility.
 Maintaining code is far easier.Maintaining code is far easier.
 Hides implementation details (just need to knowHides implementation details (just need to know
what methods to call but no need to understandwhat methods to call but no need to understand
how the methods work to use them).how the methods work to use them).
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:14
What is Java?
 Java (with a capital J) is a high-level, third
generation programming language, like C,
Fortran, Smalltalk, Perl, and many others.
 You can use Java to write computer applications
that crunch numbers, process words, play games,
store data or do any of the thousands of other
things computer software can do.
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:15
Contd:
 Compared to other programming languages,
Java is most similar to C. However although
Java shares much of C's syntax, it is not C.
Knowing how to program in C or, better yet,
C++, will certainly help you to learn Java more
quickly, but you don't need to know C to learn
Java.
 Unlike C++ Java is not a superset of C.
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:16
Contd:
 A Java compiler won't compile C code, and
most large C programs need to be changed
substantially before they can become Java
programs.
 What's most special about Java in relation to
other programming languages is that it lets you
write special programs called applets that can
be downloaded from the Internet and played
safely within a web browser.
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:17
Applets
 embed into web page using applet tagembed into web page using applet tag
 <APPLET src = "myprogram.class" width =
"100" height = "100"> < /APPLET>
 source code extends Java Applet classsource code extends Java Applet class
 has skeleton user interfacehas skeleton user interface
 programmer can add code to be executedprogrammer can add code to be executed
when applet is initialised and paintedwhen applet is initialised and painted
 programmer can easily add GUI componentsprogrammer can easily add GUI components
such as buttons, labels, textfields, scrollbars….such as buttons, labels, textfields, scrollbars….
and respond to their eventsand respond to their events
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:18
Java applications
 stand-alone programsstand-alone programs
 not GUI by defaultnot GUI by default
 text input and output to a console
 can add user interface components
 execution always starts at aexecution always starts at a main()main()
methodmethod
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:19
Applets vs. applications
 Java appletsJava applets
 a program embedded into a web page
 download and run on user's browser
(or applet viewer)
 internet programming
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:20
Applets vs. Applications
 Java applicationsJava applications
 stand-alone programs – Java is a
fully-fledged programming language
 many Java class libraries for
 GUI, graphics, networking
 data structures
 database connectivity
 we will be writing applications in thiswe will be writing applications in this
module.module.
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:21
A Brief History
 January 1996: first official release JDK 1.0
 February 1997: JDK 1.1
 May 2000: J2SDK v1.3
 May 2001: J2SDK v1.4 beta
 2002(?): J2SDK v1.5
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:22
Java is a Platform
 Java (with a capital J) is a platform for
application development.
 A platform is a loosely defined computer
industry buzzword that typically means
some combination of hardware and
system software that will mostly run all
the same software.
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:23
Java is a Platform
 Java solves the problem of platform-
independence by using byte code. The Java
compiler does not produce native executable
code for a particular machine like a C compiler
would. Instead it produces a special format
called byte code. Java byte code written in
hexadecimal, byte by byte, looks like this:
CA FE BA BE 00 03 00 2D 00 3E 08 00 3B 08
00 01 08 00 20 08
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:24
 This looks a lot like machine language,
but unlike machine language Java byte
code is exactly the same on every
platform. This byte code fragment
means the same thing on a Solaris
workstation as it does on a Macintosh
PowerBook.
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:25
Java is a Platform
 Java programs that have been compiled
into byte code still need an interpreter to
execute them on any given platform.
 The interpreter reads the byte code and
translates it into the native language of
the host machine.
 The most common such interpreter is
Sun's program java (with a little j)
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:26
Java is a Platform
 Since the byte code is completely platform
independent, only the interpreter and a few
native libraries need to be ported to get Java to
run on a new computer or operating system.
 The rest of the runtime environment including
the compiler and most of the class libraries are
written in Java. All these pieces, the javac
compiler, the java interpreter, the Java
programming language, and more are
collectively referred to as Java.
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:27
Java is Simple
 Java is an excellent teaching language,
and an excellent choice with which to
learn programming.
 The language is small so it's easy to
become fluent. The language is
interpreted so the compile-run-link cycle
is much shorter.
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:28
Java is Platform Independent
 Java was designed to not only be cross-
platform in source form like C, but also in
compiled binary form.
 Since this is frankly impossible across
processor architectures Java is compiled to an
intermediate form called byte-code.
 A Java program never really executes natively
on the host machine. Rather a special native
program called the Java interpreter reads the
byte code and executes the corresponding
native machine instructions.
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:29
Java is Platform Independent
 Thus to port Java programs to a new platform
all that is needed is to port the interpreter and
some of the library routines.
 Even the compiler is written in Java. The byte
codes are precisely defined, and remain the
same on all platforms.
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:30
Java is Platform Independent
 The second important part of making Java
cross-platform is the elimination of undefined
or architecture dependent constructs.
Integers are always four bytes long, and
floating point variables follow the IEEE 754
standard for computer arithmetic exactly.
 You don't have to worry that the meaning of
an integer is going to change if you move from
a Pentium to a PowerPC.
 In Java everything is guaranteed.
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:31
Java is High Performance
 Java byte codes can be compiled on the fly to
code that rivals C++ in speed using a "just-in-
time compiler.“
 Several companies are also working on native-
machine-architecture compilers for Java.
 These will produce executable code that does
not require a separate interpreter, and that is
indistinguishable in speed from C++.
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:32
Java is Multi-Threaded
 Java is inherently multi-threaded. A
single Java program can have many
different threads executing
independently and continuously.
 Three Java applets on the same page
can run together with each getting equal
time from the CPU with very little extra
effort on the part of the programmer.
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:33
Java is Dynamic(ly linked)
 Java does not have an explicit link phase. Java
source code is divided into .java files, roughly
one per each class in your program.
 The compiler compiles these into .class files
containing byte code. Each .java file generally
produces exactly one .class file.
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:34
Java is Dynamic(ly linked)
 The compiler searches the current directory
and directories specified in the CLASSPATH
environment variable to find other classes
explicitly referenced by name in each source
code file. If the file you're compiling depends
on other, non-compiled files the compiler will
try to find them and compile them as well.
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:35
Java is Garbage Collected
 You do not need to explicitly allocate or
deallocate memory in Java.
 Memory is allocated as needed, both on the
stack and the heap, and reclaimed by the
garbage collector when it is no longer needed.
 There's no malloc(), free(), or destructor
methods.
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:36
Characteristics of Java
• Simple
• Object-oriented
• Compiled
• Architecture neutral
• Garbage collected
• Multi-threaded
• Robust
• Secure
• Extensible
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:37
Packages
• Java provides mechanisms to organize large-
scale programs in a logical and maintainable
fashion.
 – Class --- highly cohesive functionalities
 – File --- one class or more closely related
classes
 – Package --- a collection of related classes or
packages
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:38
A simple Java application
class HelloJava
{
public static void main (String args[])
{
System.out.println("Hello Java!");
}
}
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:39
Writing Java code
 When you've chosen your text editor, type or
copy the above program into a new file.
 Like C and unlike Fortran, Java is case sensitive
so System.out.println is not the same as
system.out.println. CLASS is not the same as
class, and so on.
 there are three steps to creating a Java
program:
 – writing the code
 – compiling the code
 – running the code
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:40
First Java Program
 Under Windows, it's similar. You just do
this in a DOS shell.
C:> javac HelloWorld.java
C:> java HelloWorld
Hello World
 C:>
• Notice that you use the .java extension
when compiling a file, but you do not
use the .class extension when running a
file.
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:41
First Java Program
 Under Windows (98 and before) you set the
CLASSPATH environment variable with a DOS
command like
 C:> SET
CLASSPATH=C:JDKJAVACLASSES;c:javalib
classes.zip
For Newer Windows platforms (including
Windows XP), type the following-
C:> set path=C:j2sdk1.4.0-rcbin
And press ENTER
 (where j2sdk1.4.0 is the folder in your root
(C:>) drive, where Java2SDK is installed)
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:42
First Java Program
 The CLASSPATH variable is also
important when you run Java applets,
not just when you compile them. It tells
the web browser or applet viewer where
it should look to find the referenced
.class files.
 If the CLASSPATH is set improperly,
you'll probably see messages like
"Applet could not start."
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:43
 If the CLASSPATH environment variable
has not been set, and you do not specify
one on the command line, then Java
sets the CLASSPATH to the default.
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:44
The class and its method in
JAVA
 name of class is same as name of filename of class is same as name of file
(which has(which has ..java extension)java extension)
 body of class surrounded by { }body of class surrounded by { }
 this class has one method called mainthis class has one method called main
 all Java applications must have a main
method in one of the classes
 execution starts here
 body of method within { }
 all other statements end with semicolon;all other statements end with semicolon;
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:45
Java keywords
 keywords appear in boldkeywords appear in bold
 reserved by Java for predefined
purpose
 don’t use them for your own variable,
attribute or method names!
 publicpublic
 visibility could be private
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:46
Java keywords
 voidvoid
 method does not return a value
 staticstatic
 the main method belongs to the Hello
class, and not an instance (object) of
the class.
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:47
Comments
 important for documentation!!!!important for documentation!!!!
 ignored by compilerignored by compiler
//// single line (or part of line)single line (or part of line)
/* multiple line comments go here/* multiple line comments go here
everything between the markseverything between the marks
is ignored */is ignored */
Copyrights© 2008
BVU Amplify DITM
Core JavaCore Java
Page:48
THANK YOUTHANK YOU

More Related Content

Viewers also liked

E business--PPT BY VIKAS JAGTAP
E business--PPT BY VIKAS JAGTAPE business--PPT BY VIKAS JAGTAP
E business--PPT BY VIKAS JAGTAPVikas Jagtap
 
Servlet ppt by vikas jagtap
Servlet ppt by vikas jagtapServlet ppt by vikas jagtap
Servlet ppt by vikas jagtapVikas Jagtap
 
Simple Network Management Protocol by vikas jagtap
Simple Network Management Protocol by vikas jagtapSimple Network Management Protocol by vikas jagtap
Simple Network Management Protocol by vikas jagtapVikas Jagtap
 
ip addressing & routing
 ip addressing & routing ip addressing & routing
ip addressing & routingVikas Jagtap
 
java Servlet technology
java Servlet technologyjava Servlet technology
java Servlet technologyTanmoy Barman
 

Viewers also liked (7)

E business--PPT BY VIKAS JAGTAP
E business--PPT BY VIKAS JAGTAPE business--PPT BY VIKAS JAGTAP
E business--PPT BY VIKAS JAGTAP
 
Servlet ppt by vikas jagtap
Servlet ppt by vikas jagtapServlet ppt by vikas jagtap
Servlet ppt by vikas jagtap
 
Simple Network Management Protocol by vikas jagtap
Simple Network Management Protocol by vikas jagtapSimple Network Management Protocol by vikas jagtap
Simple Network Management Protocol by vikas jagtap
 
ip addressing & routing
 ip addressing & routing ip addressing & routing
ip addressing & routing
 
Jdbc ppt
Jdbc pptJdbc ppt
Jdbc ppt
 
java Servlet technology
java Servlet technologyjava Servlet technology
java Servlet technology
 
Jsp ppt
Jsp pptJsp ppt
Jsp ppt
 

Similar to Cr java concept by vikas jagtap

Java Programming (M&M)
Java Programming (M&M)Java Programming (M&M)
Java Programming (M&M)mafffffe19
 
10 interesting things about java
10 interesting things about java10 interesting things about java
10 interesting things about javakanchanmahajan23
 
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
 
Online gas booking project in java
Online gas booking project in javaOnline gas booking project in java
Online gas booking project in javas4al_com
 
MODULE_1_The History and Evolution of Java.pptx
MODULE_1_The History and Evolution of Java.pptxMODULE_1_The History and Evolution of Java.pptx
MODULE_1_The History and Evolution of Java.pptxVeerannaKotagi1
 
Core Java Slides
Core Java SlidesCore Java Slides
Core Java SlidesVinit Vyas
 
JavaClassPresentation
JavaClassPresentationJavaClassPresentation
JavaClassPresentationjuliasceasor
 
Java Semimar Slide (Cetpa)
Java Semimar Slide (Cetpa)Java Semimar Slide (Cetpa)
Java Semimar Slide (Cetpa)Pratima Parida
 
Java Semimar Slide (Cetpa)
Java Semimar Slide (Cetpa)Java Semimar Slide (Cetpa)
Java Semimar Slide (Cetpa)Pratima Parida
 
Introducción a la progrogramación orientada a objetos con Java
Introducción a la progrogramación orientada a objetos con JavaIntroducción a la progrogramación orientada a objetos con Java
Introducción a la progrogramación orientada a objetos con JavaFacultad de Ciencias y Sistemas
 
TechSearchWeb Tutorials.pdf
TechSearchWeb Tutorials.pdfTechSearchWeb Tutorials.pdf
TechSearchWeb Tutorials.pdfTechSearchWeb
 
Technology Tutorial.pdf
Technology Tutorial.pdfTechnology Tutorial.pdf
Technology Tutorial.pdfTechSearchWeb
 
Chapter 1 introduction to java technology
Chapter 1 introduction to java technologyChapter 1 introduction to java technology
Chapter 1 introduction to java technologysshhzap
 
iPhone Workshop Mobile Monday Ahmedabad
iPhone Workshop Mobile Monday AhmedabadiPhone Workshop Mobile Monday Ahmedabad
iPhone Workshop Mobile Monday Ahmedabadmomoahmedabad
 

Similar to Cr java concept by vikas jagtap (20)

130700548484460000
130700548484460000130700548484460000
130700548484460000
 
Java Programming (M&M)
Java Programming (M&M)Java Programming (M&M)
Java Programming (M&M)
 
10 interesting things about java
10 interesting things about java10 interesting things about java
10 interesting things about 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
 
Online gas booking project in java
Online gas booking project in javaOnline gas booking project in java
Online gas booking project in java
 
Java
JavaJava
Java
 
MODULE_1_The History and Evolution of Java.pptx
MODULE_1_The History and Evolution of Java.pptxMODULE_1_The History and Evolution of Java.pptx
MODULE_1_The History and Evolution of Java.pptx
 
Core Java Slides
Core Java SlidesCore Java Slides
Core Java Slides
 
Java 2 computer science.pptx
Java 2 computer science.pptxJava 2 computer science.pptx
Java 2 computer science.pptx
 
JavaClassPresentation
JavaClassPresentationJavaClassPresentation
JavaClassPresentation
 
Java Semimar Slide (Cetpa)
Java Semimar Slide (Cetpa)Java Semimar Slide (Cetpa)
Java Semimar Slide (Cetpa)
 
Java Semimar Slide (Cetpa)
Java Semimar Slide (Cetpa)Java Semimar Slide (Cetpa)
Java Semimar Slide (Cetpa)
 
Introducción a la progrogramación orientada a objetos con Java
Introducción a la progrogramación orientada a objetos con JavaIntroducción a la progrogramación orientada a objetos con Java
Introducción a la progrogramación orientada a objetos con Java
 
TechSearchWeb Tutorials.pdf
TechSearchWeb Tutorials.pdfTechSearchWeb Tutorials.pdf
TechSearchWeb Tutorials.pdf
 
TechSearchWeb.pdf
TechSearchWeb.pdfTechSearchWeb.pdf
TechSearchWeb.pdf
 
Technology Tutorial.pdf
Technology Tutorial.pdfTechnology Tutorial.pdf
Technology Tutorial.pdf
 
Java session2
Java session2Java session2
Java session2
 
Chapter 1 introduction to java technology
Chapter 1 introduction to java technologyChapter 1 introduction to java technology
Chapter 1 introduction to java technology
 
iPhone Workshop Mobile Monday Ahmedabad
iPhone Workshop Mobile Monday AhmedabadiPhone Workshop Mobile Monday Ahmedabad
iPhone Workshop Mobile Monday Ahmedabad
 

More from Vikas Jagtap

broad band networks
 broad band networks broad band networks
broad band networksVikas Jagtap
 
KNOWLEDGE BASE SYSTEMS
KNOWLEDGE  BASE SYSTEMSKNOWLEDGE  BASE SYSTEMS
KNOWLEDGE BASE SYSTEMSVikas Jagtap
 
ADVANCE DATABASE MANAGEMENT SYSTEM CONCEPTS & ARCHITECTURE by vikas jagtap
ADVANCE DATABASE MANAGEMENT SYSTEM CONCEPTS & ARCHITECTURE by vikas jagtapADVANCE DATABASE MANAGEMENT SYSTEM CONCEPTS & ARCHITECTURE by vikas jagtap
ADVANCE DATABASE MANAGEMENT SYSTEM CONCEPTS & ARCHITECTURE by vikas jagtapVikas Jagtap
 
Overview of Object-Oriented Concepts Characteristics by vikas jagtap
Overview of Object-Oriented Concepts Characteristics by vikas jagtapOverview of Object-Oriented Concepts Characteristics by vikas jagtap
Overview of Object-Oriented Concepts Characteristics by vikas jagtapVikas Jagtap
 
things which make think ooh!!!!!!!! by vikas jagtap
things which make think ooh!!!!!!!! by vikas jagtapthings which make think ooh!!!!!!!! by vikas jagtap
things which make think ooh!!!!!!!! by vikas jagtapVikas Jagtap
 
Dear son daughter by vikas jagtap
Dear son daughter   by vikas jagtapDear son daughter   by vikas jagtap
Dear son daughter by vikas jagtapVikas Jagtap
 
Double vision by vikas jagtap
Double vision by vikas jagtapDouble vision by vikas jagtap
Double vision by vikas jagtapVikas Jagtap
 
Dubai by vikas jagtap
Dubai by vikas jagtapDubai by vikas jagtap
Dubai by vikas jagtapVikas Jagtap
 
District of maharashtra by vikas jagtap
District of maharashtra by vikas jagtapDistrict of maharashtra by vikas jagtap
District of maharashtra by vikas jagtapVikas Jagtap
 
Animation technique
Animation techniqueAnimation technique
Animation techniqueVikas Jagtap
 
An Introduction to BLUETOOTH TECHNOLOGY
An Introduction to BLUETOOTH TECHNOLOGYAn Introduction to BLUETOOTH TECHNOLOGY
An Introduction to BLUETOOTH TECHNOLOGYVikas Jagtap
 
domain network services (dns)
 domain network services (dns) domain network services (dns)
domain network services (dns)Vikas Jagtap
 
Introduction to networking by vikas jagtap
 Introduction to networking by vikas jagtap Introduction to networking by vikas jagtap
Introduction to networking by vikas jagtapVikas Jagtap
 
Transformingschoolculture
TransformingschoolcultureTransformingschoolculture
TransformingschoolcultureVikas Jagtap
 
Entrepreneurship (1)
Entrepreneurship (1)Entrepreneurship (1)
Entrepreneurship (1)Vikas Jagtap
 

More from Vikas Jagtap (20)

broad band networks
 broad band networks broad band networks
broad band networks
 
KNOWLEDGE BASE SYSTEMS
KNOWLEDGE  BASE SYSTEMSKNOWLEDGE  BASE SYSTEMS
KNOWLEDGE BASE SYSTEMS
 
ADVANCE DATABASE MANAGEMENT SYSTEM CONCEPTS & ARCHITECTURE by vikas jagtap
ADVANCE DATABASE MANAGEMENT SYSTEM CONCEPTS & ARCHITECTURE by vikas jagtapADVANCE DATABASE MANAGEMENT SYSTEM CONCEPTS & ARCHITECTURE by vikas jagtap
ADVANCE DATABASE MANAGEMENT SYSTEM CONCEPTS & ARCHITECTURE by vikas jagtap
 
Overview of Object-Oriented Concepts Characteristics by vikas jagtap
Overview of Object-Oriented Concepts Characteristics by vikas jagtapOverview of Object-Oriented Concepts Characteristics by vikas jagtap
Overview of Object-Oriented Concepts Characteristics by vikas jagtap
 
things which make think ooh!!!!!!!! by vikas jagtap
things which make think ooh!!!!!!!! by vikas jagtapthings which make think ooh!!!!!!!! by vikas jagtap
things which make think ooh!!!!!!!! by vikas jagtap
 
Paradise on earth
Paradise on earthParadise on earth
Paradise on earth
 
Dear son daughter by vikas jagtap
Dear son daughter   by vikas jagtapDear son daughter   by vikas jagtap
Dear son daughter by vikas jagtap
 
Double vision by vikas jagtap
Double vision by vikas jagtapDouble vision by vikas jagtap
Double vision by vikas jagtap
 
Dubai by vikas jagtap
Dubai by vikas jagtapDubai by vikas jagtap
Dubai by vikas jagtap
 
District of maharashtra by vikas jagtap
District of maharashtra by vikas jagtapDistrict of maharashtra by vikas jagtap
District of maharashtra by vikas jagtap
 
Animation technique
Animation techniqueAnimation technique
Animation technique
 
Amit
AmitAmit
Amit
 
An Introduction to BLUETOOTH TECHNOLOGY
An Introduction to BLUETOOTH TECHNOLOGYAn Introduction to BLUETOOTH TECHNOLOGY
An Introduction to BLUETOOTH TECHNOLOGY
 
Network security
 Network security Network security
Network security
 
domain network services (dns)
 domain network services (dns) domain network services (dns)
domain network services (dns)
 
Introduction to networking by vikas jagtap
 Introduction to networking by vikas jagtap Introduction to networking by vikas jagtap
Introduction to networking by vikas jagtap
 
Transformingschoolculture
TransformingschoolcultureTransformingschoolculture
Transformingschoolculture
 
Marketing
MarketingMarketing
Marketing
 
Entrepreneurship (1)
Entrepreneurship (1)Entrepreneurship (1)
Entrepreneurship (1)
 
HTML
HTML HTML
HTML
 

Recently uploaded

Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactdawncurless
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3JemimahLaneBuaron
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdfssuser54595a
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersChitralekhaTherkar
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxiammrhaywood
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991RKavithamani
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Krashi Coaching
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformChameera Dedduwage
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeThiyagu K
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 

Recently uploaded (20)

Accessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impactAccessible design: Minimum effort, maximum impact
Accessible design: Minimum effort, maximum impact
 
Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3Q4-W6-Restating Informational Text Grade 3
Q4-W6-Restating Informational Text Grade 3
 
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
18-04-UA_REPORT_MEDIALITERAСY_INDEX-DM_23-1-final-eng.pdf
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
Micromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of PowdersMicromeritics - Fundamental and Derived Properties of Powders
Micromeritics - Fundamental and Derived Properties of Powders
 
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptxSOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
SOCIAL AND HISTORICAL CONTEXT - LFTVD.pptx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1Código Creativo y Arte de Software | Unidad 1
Código Creativo y Arte de Software | Unidad 1
 
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
Industrial Policy - 1948, 1956, 1973, 1977, 1980, 1991
 
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
Kisan Call Centre - To harness potential of ICT in Agriculture by answer farm...
 
A Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy ReformA Critique of the Proposed National Education Policy Reform
A Critique of the Proposed National Education Policy Reform
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
Measures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and ModeMeasures of Central Tendency: Mean, Median and Mode
Measures of Central Tendency: Mean, Median and Mode
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Staff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSDStaff of Color (SOC) Retention Efforts DDSD
Staff of Color (SOC) Retention Efforts DDSD
 

Cr java concept by vikas jagtap

  • 1. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:1 CORE-JAVA By SimiBy Simi
  • 2. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:2 First, a bit of background…  11stst Generation – machine languageGeneration – machine language  (raw machine code – lots of binary 0100101010001000111)  22ndnd Generation – assembly languageGeneration – assembly language  (mnemonic representation – short series of chars to represent binary)  33rdrd Generation – structured programmingGeneration – structured programming  (e.g. Pascal, C, C++, Java)  44thth Generation – application specificGeneration – application specific  (SQL, Mathematica, RPG II, PostScript)  55thth Generation – combining artificial intelligenceGeneration – combining artificial intelligence  (best not mentioned…)
  • 3. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:3 Towards Structured Programming  As computer programs become largerAs computer programs become larger and more complex, more errors areand more complex, more errors are introduced.introduced.  It has been estimated that there are 15It has been estimated that there are 15 bugs in every 1000 lines of commercialbugs in every 1000 lines of commercial code.code.  Windows 2000 had 40 million lines ofWindows 2000 had 40 million lines of code!code!  Most bugs are caused by poor memoryMost bugs are caused by poor memory management.management.
  • 4. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:4 Contd:  Clearly there is a need for a structuredClearly there is a need for a structured programming language that helps inprogramming language that helps in reducing the number of errors andreducing the number of errors and speeds development for programmingspeeds development for programming teams.teams.  CC →→ C++C++ →→ JavaJava
  • 5. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:5 Contd:  Functional ProgrammingFunctional Programming →→ ObjectObject OrientationOrientation ““C makes it easy to shoot yourself in theC makes it easy to shoot yourself in the foot; C++ makes it harder, but when itfoot; C++ makes it harder, but when it happens you tend to take off the wholehappens you tend to take off the whole leg!”leg!”
  • 6. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:6 What is Object-Oriented code?  Procedural coding is just a list of instructions.Procedural coding is just a list of instructions.  Object-oriented code has a lot of similarity withObject-oriented code has a lot of similarity with code from other procedural languages.code from other procedural languages.  Basically, a lot of the ‘words’ are the same but theBasically, a lot of the ‘words’ are the same but the way the words are put together (the structure) isway the words are put together (the structure) is different.different.
  • 7. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:7 Contd:  Object-oriented coding does also contain lists ofObject-oriented coding does also contain lists of instructions but these lists are bound to specificinstructions but these lists are bound to specific objects.objects.  What an object actually represents is up to theWhat an object actually represents is up to the programmer.programmer.
  • 8. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:8 Simple Example  AA car is an object (in the real world) and in ourcar is an object (in the real world) and in our program we can make a software object toprogram we can make a software object to represent it.represent it.  Fundamentally, an object contains data andFundamentally, an object contains data and methods which can act on that data.methods which can act on that data.  The data we might want to have in our ‘software’The data we might want to have in our ‘software’ car could be things like: body colour, engine size,car could be things like: body colour, engine size, current speed, whether it has electric windows etc.current speed, whether it has electric windows etc. Basically it’s up to you.Basically it’s up to you.
  • 9. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:9 Simple Example  The methods we might want our ‘car’ to haveThe methods we might want our ‘car’ to have could be things like: accelerate, brake, respraycould be things like: accelerate, brake, respray body, open passenger window etc. Again, it’s up tobody, open passenger window etc. Again, it’s up to you.you.  Whatever you need your software car to modelWhatever you need your software car to model from the real world object must be present in yourfrom the real world object must be present in your code.code.  The OO syntax enables you to do this intuitively.The OO syntax enables you to do this intuitively.
  • 10. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:10 What technology does it replace?  Procedural programming (C, Visual Basic, FortranProcedural programming (C, Visual Basic, Fortran etc.)etc.)  In procedural programming, functions were theIn procedural programming, functions were the most important part of the software.most important part of the software.  Where and how the data was stored was secondaryWhere and how the data was stored was secondary (at best).(at best).  Procedural code is process-oriented, OO code isProcedural code is process-oriented, OO code is data-oriented.data-oriented.  In procedural programming, if your code is in errorIn procedural programming, if your code is in error then it is relatively easy to fix but incorrect datathen it is relatively easy to fix but incorrect data may bemay be impossibleimpossible to fix!to fix!
  • 11. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:11 Java (why use it?) Advantages over C & C++Advantages over C & C++  WORA - Write Once, Run Anywhere (portable).WORA - Write Once, Run Anywhere (portable).  Security (can run “untrusted” code safely).Security (can run “untrusted” code safely).  Robust memory management (opaque references,Robust memory management (opaque references, automatic garbage collection)automatic garbage collection)  Network-centric programming.Network-centric programming.
  • 12. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:12 Java (why use it?)  Multi-threaded (multiple simultaneous tasks).Multi-threaded (multiple simultaneous tasks).  Dynamic & extensible.Dynamic & extensible.  Classes stored in separate files  Loaded only when needed  Can dynamically extend itself to expand its functionality (even over a network and the Internet!)
  • 13. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:13 How does it help?  Large projects can be broken down into modulesLarge projects can be broken down into modules more easily.more easily.  Aids understanding.Aids understanding.  Groupwork is easier.Groupwork is easier.  Less chance of data corruption.Less chance of data corruption.  Aids reusability/extensibility.Aids reusability/extensibility.  Maintaining code is far easier.Maintaining code is far easier.  Hides implementation details (just need to knowHides implementation details (just need to know what methods to call but no need to understandwhat methods to call but no need to understand how the methods work to use them).how the methods work to use them).
  • 14. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:14 What is Java?  Java (with a capital J) is a high-level, third generation programming language, like C, Fortran, Smalltalk, Perl, and many others.  You can use Java to write computer applications that crunch numbers, process words, play games, store data or do any of the thousands of other things computer software can do.
  • 15. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:15 Contd:  Compared to other programming languages, Java is most similar to C. However although Java shares much of C's syntax, it is not C. Knowing how to program in C or, better yet, C++, will certainly help you to learn Java more quickly, but you don't need to know C to learn Java.  Unlike C++ Java is not a superset of C.
  • 16. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:16 Contd:  A Java compiler won't compile C code, and most large C programs need to be changed substantially before they can become Java programs.  What's most special about Java in relation to other programming languages is that it lets you write special programs called applets that can be downloaded from the Internet and played safely within a web browser.
  • 17. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:17 Applets  embed into web page using applet tagembed into web page using applet tag  <APPLET src = "myprogram.class" width = "100" height = "100"> < /APPLET>  source code extends Java Applet classsource code extends Java Applet class  has skeleton user interfacehas skeleton user interface  programmer can add code to be executedprogrammer can add code to be executed when applet is initialised and paintedwhen applet is initialised and painted  programmer can easily add GUI componentsprogrammer can easily add GUI components such as buttons, labels, textfields, scrollbars….such as buttons, labels, textfields, scrollbars…. and respond to their eventsand respond to their events
  • 18. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:18 Java applications  stand-alone programsstand-alone programs  not GUI by defaultnot GUI by default  text input and output to a console  can add user interface components  execution always starts at aexecution always starts at a main()main() methodmethod
  • 19. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:19 Applets vs. applications  Java appletsJava applets  a program embedded into a web page  download and run on user's browser (or applet viewer)  internet programming
  • 20. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:20 Applets vs. Applications  Java applicationsJava applications  stand-alone programs – Java is a fully-fledged programming language  many Java class libraries for  GUI, graphics, networking  data structures  database connectivity  we will be writing applications in thiswe will be writing applications in this module.module.
  • 21. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:21 A Brief History  January 1996: first official release JDK 1.0  February 1997: JDK 1.1  May 2000: J2SDK v1.3  May 2001: J2SDK v1.4 beta  2002(?): J2SDK v1.5
  • 22. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:22 Java is a Platform  Java (with a capital J) is a platform for application development.  A platform is a loosely defined computer industry buzzword that typically means some combination of hardware and system software that will mostly run all the same software.
  • 23. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:23 Java is a Platform  Java solves the problem of platform- independence by using byte code. The Java compiler does not produce native executable code for a particular machine like a C compiler would. Instead it produces a special format called byte code. Java byte code written in hexadecimal, byte by byte, looks like this: CA FE BA BE 00 03 00 2D 00 3E 08 00 3B 08 00 01 08 00 20 08
  • 24. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:24  This looks a lot like machine language, but unlike machine language Java byte code is exactly the same on every platform. This byte code fragment means the same thing on a Solaris workstation as it does on a Macintosh PowerBook.
  • 25. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:25 Java is a Platform  Java programs that have been compiled into byte code still need an interpreter to execute them on any given platform.  The interpreter reads the byte code and translates it into the native language of the host machine.  The most common such interpreter is Sun's program java (with a little j)
  • 26. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:26 Java is a Platform  Since the byte code is completely platform independent, only the interpreter and a few native libraries need to be ported to get Java to run on a new computer or operating system.  The rest of the runtime environment including the compiler and most of the class libraries are written in Java. All these pieces, the javac compiler, the java interpreter, the Java programming language, and more are collectively referred to as Java.
  • 27. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:27 Java is Simple  Java is an excellent teaching language, and an excellent choice with which to learn programming.  The language is small so it's easy to become fluent. The language is interpreted so the compile-run-link cycle is much shorter.
  • 28. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:28 Java is Platform Independent  Java was designed to not only be cross- platform in source form like C, but also in compiled binary form.  Since this is frankly impossible across processor architectures Java is compiled to an intermediate form called byte-code.  A Java program never really executes natively on the host machine. Rather a special native program called the Java interpreter reads the byte code and executes the corresponding native machine instructions.
  • 29. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:29 Java is Platform Independent  Thus to port Java programs to a new platform all that is needed is to port the interpreter and some of the library routines.  Even the compiler is written in Java. The byte codes are precisely defined, and remain the same on all platforms.
  • 30. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:30 Java is Platform Independent  The second important part of making Java cross-platform is the elimination of undefined or architecture dependent constructs. Integers are always four bytes long, and floating point variables follow the IEEE 754 standard for computer arithmetic exactly.  You don't have to worry that the meaning of an integer is going to change if you move from a Pentium to a PowerPC.  In Java everything is guaranteed.
  • 31. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:31 Java is High Performance  Java byte codes can be compiled on the fly to code that rivals C++ in speed using a "just-in- time compiler.“  Several companies are also working on native- machine-architecture compilers for Java.  These will produce executable code that does not require a separate interpreter, and that is indistinguishable in speed from C++.
  • 32. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:32 Java is Multi-Threaded  Java is inherently multi-threaded. A single Java program can have many different threads executing independently and continuously.  Three Java applets on the same page can run together with each getting equal time from the CPU with very little extra effort on the part of the programmer.
  • 33. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:33 Java is Dynamic(ly linked)  Java does not have an explicit link phase. Java source code is divided into .java files, roughly one per each class in your program.  The compiler compiles these into .class files containing byte code. Each .java file generally produces exactly one .class file.
  • 34. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:34 Java is Dynamic(ly linked)  The compiler searches the current directory and directories specified in the CLASSPATH environment variable to find other classes explicitly referenced by name in each source code file. If the file you're compiling depends on other, non-compiled files the compiler will try to find them and compile them as well.
  • 35. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:35 Java is Garbage Collected  You do not need to explicitly allocate or deallocate memory in Java.  Memory is allocated as needed, both on the stack and the heap, and reclaimed by the garbage collector when it is no longer needed.  There's no malloc(), free(), or destructor methods.
  • 36. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:36 Characteristics of Java • Simple • Object-oriented • Compiled • Architecture neutral • Garbage collected • Multi-threaded • Robust • Secure • Extensible
  • 37. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:37 Packages • Java provides mechanisms to organize large- scale programs in a logical and maintainable fashion.  – Class --- highly cohesive functionalities  – File --- one class or more closely related classes  – Package --- a collection of related classes or packages
  • 38. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:38 A simple Java application class HelloJava { public static void main (String args[]) { System.out.println("Hello Java!"); } }
  • 39. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:39 Writing Java code  When you've chosen your text editor, type or copy the above program into a new file.  Like C and unlike Fortran, Java is case sensitive so System.out.println is not the same as system.out.println. CLASS is not the same as class, and so on.  there are three steps to creating a Java program:  – writing the code  – compiling the code  – running the code
  • 40. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:40 First Java Program  Under Windows, it's similar. You just do this in a DOS shell. C:> javac HelloWorld.java C:> java HelloWorld Hello World  C:> • Notice that you use the .java extension when compiling a file, but you do not use the .class extension when running a file.
  • 41. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:41 First Java Program  Under Windows (98 and before) you set the CLASSPATH environment variable with a DOS command like  C:> SET CLASSPATH=C:JDKJAVACLASSES;c:javalib classes.zip For Newer Windows platforms (including Windows XP), type the following- C:> set path=C:j2sdk1.4.0-rcbin And press ENTER  (where j2sdk1.4.0 is the folder in your root (C:>) drive, where Java2SDK is installed)
  • 42. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:42 First Java Program  The CLASSPATH variable is also important when you run Java applets, not just when you compile them. It tells the web browser or applet viewer where it should look to find the referenced .class files.  If the CLASSPATH is set improperly, you'll probably see messages like "Applet could not start."
  • 43. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:43  If the CLASSPATH environment variable has not been set, and you do not specify one on the command line, then Java sets the CLASSPATH to the default.
  • 44. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:44 The class and its method in JAVA  name of class is same as name of filename of class is same as name of file (which has(which has ..java extension)java extension)  body of class surrounded by { }body of class surrounded by { }  this class has one method called mainthis class has one method called main  all Java applications must have a main method in one of the classes  execution starts here  body of method within { }  all other statements end with semicolon;all other statements end with semicolon;
  • 45. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:45 Java keywords  keywords appear in boldkeywords appear in bold  reserved by Java for predefined purpose  don’t use them for your own variable, attribute or method names!  publicpublic  visibility could be private
  • 46. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:46 Java keywords  voidvoid  method does not return a value  staticstatic  the main method belongs to the Hello class, and not an instance (object) of the class.
  • 47. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:47 Comments  important for documentation!!!!important for documentation!!!!  ignored by compilerignored by compiler //// single line (or part of line)single line (or part of line) /* multiple line comments go here/* multiple line comments go here everything between the markseverything between the marks is ignored */is ignored */
  • 48. Copyrights© 2008 BVU Amplify DITM Core JavaCore Java Page:48 THANK YOUTHANK YOU