0% found this document useful (0 votes)
35 views

Java Is General Purpose: Wednesday, December 8, 2021 1

Java was developed by Sun Microsystems in 1991 as a general purpose, object-oriented programming language. It was designed for use in consumer electronic devices to make software development simpler, more reliable and portable. Java removes problematic features of C/C++, making it a simple yet powerful language. It is platform independent, object-oriented, robust, secure, distributed, multithreaded and has a high performance.

Uploaded by

Suman Rathore
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
35 views

Java Is General Purpose: Wednesday, December 8, 2021 1

Java was developed by Sun Microsystems in 1991 as a general purpose, object-oriented programming language. It was designed for use in consumer electronic devices to make software development simpler, more reliable and portable. Java removes problematic features of C/C++, making it a simple yet powerful language. It is platform independent, object-oriented, robust, secure, distributed, multithreaded and has a high performance.

Uploaded by

Suman Rathore
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as PPT, PDF, TXT or read online on Scribd
You are on page 1/ 19

JAVA

 Java is general purpose object-oriented programming


language developed by Sun Microsystems of USA in
1991.
 Java was designed for the development of software for

consumer electronic devices like TVs, VCRs,and other


electronic machines.

 It has removed those features of C/C++ that were


considered as sources of problems and thus made java a
really simple, reliable, portable, and powerful language.

Wednesday, December 8, 2021 [email protected] 1


Features of Java
• Compiled and Interpreted
• Platform-Independent and Portable
• Object-Oriented
• Robust and Secure
• Distributed
• Simple, Small and Familiar
• Multithreaded and Interactive
• High Performance
• Dynamic and Extensible

Wednesday, December 8, 2021 [email protected] 2


JDK Editions
 Java Standard Edition (J2SE)
– J2SE can be used to develop client-side standalone
applications or applets.
 Java Enterprise Edition (J2EE)
– J2EE can be used to develop server-side appli. such as
 Java servlets
 Java Server Pages.
 Java Micro Edition (J2ME)
– J2ME can be used to develop applications for mobile
devices such as cell phones.

Wednesday, December 8, 2021 [email protected] 3


1. Java, J2SE, JSDK, JDK, JRE

 There are several 'Java' names:


 Java is the name of the language
 Java 2 is the current version

 the language + tools (e.g. compiler) is called J2S


E, the Java 2 Standard Edition
 J2SE 1.5.0. is the current version
 its also known as J2SE 5.0 the same
thing
Wednesday, December 8, 2021 [email protected] 4
 There are two version of J2SE which contain
different amounts of tools:
 JSDK: the full version
 JRE: just enough tools to run already compiled pr
ograms

Wednesday, December 8, 2021 [email protected] 5


 JSDK
 stands for "Java Software Development Kit

 JDK is the old name for JSDK


 don't be surprised to also see J2SDK
or Java SDK

Wednesday, December 8, 2021 [email protected] 6


Java History

1 Jdk 1.0 (January 23, 1996) (Unsupported)


2 Jdk 1.1 (February 19, 1997) (Unsupported)
3 J2se 1.2 (December 8, 1998) (Unsupported)
4 J2se 1.3 (May 8, 2000) (Unsupported)
5 J2se 1.4 (February 6, 2002) (Eol)
6 J2se 5.0 (September 30, 2004) (Eol)
7 Java Se 6 (December 11, 2006) (Supported)
7.1 Java Se 6 Update 10
8 Java Se 7

Wednesday, December 8, 2021 [email protected] 7


JAVA and C
 Java does not include the C unique statement keywords
sizeof and typedef.
 Java does not contain the data types struct and union.
 Java does not define the type modifiers keywords auto,
extern, register, signed, and unsigned.
 Java does not support an explicit pointer type.
 Java does not have a preprocessor and therefore we
cannot use #define, #include, and #ifdef statements.
 Java adds new operators such as instanceof >>>.

Wednesday, December 8, 2021 [email protected] 8


Java and C++
 Java is a true object-oriented language while C++ is
basically C with object-oriented extension .
 Java does not support operator overloading.
 Java does not support multiple inheritance of classes. This is
accomplished using a new features called “interface”.
 Java does not support global variable. Every variable and
method is declared within a class and forms part of that
class.
 Java does not use pointers.
 Java has replaced the destructor function with a finalize()
function.
 There is no header file in Java.

Wednesday, December 8, 2021 [email protected] 9


Java Program Structute

Documentation Section

Package Statement

Import Statements

Interface Statements

Class Definitions

Main method class


{
Main method definition
}
Wednesday, December 8, 2021 [email protected] 10
Implementing the Java Program

 Creating the Java Program

 Compiling the Program

 Running the Program

Wednesday, December 8, 2021 [email protected] 11


JAVA Virtual Machine

Java Program Java Compiler Virtual Machine

Source Program Byte Code

Bytecode Java Interpreter Machine Code

Virtual Machine Real Machine

Wednesday, December 8, 2021 [email protected] 12


Data Types
 Java has two main categories of data types:
 Primitive data types
 Built in data types

 Many very similar to C++ (int, double, char, etc.)

 Variables holding primitive data types always hold the actual

value, never a reference


 Reference data types
 Arrays and user defined data types (i.e. Classes, Interfaces)

 Can only be accessed through reference variables

Wednesday, December 8, 2021 [email protected] 13


Primitive Data Types
 Integer data types
 byte – 8 bits (values from -128 to +127)
 short – 16 bits (-32768 to +32767)
 int – 32 bits (very big numbers)
 long – 64 bits (even bigger numbers)
 Characters
 char – 16 bits, represented in unicode, not ASCII!
 Floating point data types
 float – 4 bytes (-3.4 x 1038 to +3.4 x 1038)
 double – 8 bytes (-1.7 x 10308 to 1.7 x 10308)
 Boolean data
 boolean
 can only have the value true or false
 Unlike C++, cannot be cast to an int (or any other data type)

Wednesday, December 8, 2021 [email protected] 14


Operators
 Arithmetic
 +,-,*,/,%,++,--
 Logic
 &,|,^,~,<<,>>,>>>
 Assignment
 =, +=, -=, etc..
 Comparison
 <,<=,>,>=,==,!=
 Work just like in C++, except for special String
support

Wednesday, December 8, 2021 [email protected] 15


Control Structures
 if/else, for, while, do/while, switch
 Basically work the same as in C/C++
i = 0; for(i = 0; i < 10; i++) {
while(i < 10) { a += i;
a += i; }
i++;
} if(a > 3) { switch(i) {
a = 3; case 1:
i = 0; } string = “foo”;
do { else { case 2:
a += i; a = 0; string = “bar”;
i++; } default:
} while(i < 10); string = “”;
}
Wednesday, December 8, 2021 [email protected] 16
Control Structures
 Java also has support for continue and break
keywords
 Again, work very similar to C/C++

for(i = 0; i < 10; i++) { for(i = 0; i < 10; i++) {


a += i; if(i == 5)
if(a > 100) continue;
break; a += i;
} }

 Also note: switch statements require the condition


variable to be a char, byte, short or int

Wednesday, December 8, 2021 [email protected] 17


Working With Java Objects
 Encapsulation

 Inheritance

 Polymorphisms

 Constructors

 Garbage Collection and Finalize


Wednesday, December 8, 2021 [email protected] 18
Method Overloading

 In java, it is possible to create methods that


have the same name, but different parameter
lists and diffrerent definitions. This is called
method overloading.

 Method overloading is used when objects are


required to perform similar tasks but different
input parameters.

Wednesday, December 8, 2021 [email protected] 19

You might also like