SlideShare a Scribd company logo
INTRODUCTIONTO OOPS
Object Oriented Programming with JAVA
Mr. RAMALINGHAM KRISHNAMOORTHY, ME.,
LECTURER/COMPUTER ENGINEERING DEPARTMENT,
V.S.V.N POLYTECHNIC COLLEGE,
(VIRUDHUNAGARS.VELLAICHAMY NADAR POLYTECHNICCOLLEGE)
VIRUDHUNAGAR
Paradigms of Programming Languages
A programming paradigm is a style or “way” of
programming. Some languages make it easy to write in
some paradigms but not others.
List of Common Paradigms
Imperative Programming:
Control flow in imperative programming is explicit: commands show how the computation takes place, step by
step. Each step affects the global state of the computation.
Structured Programming:
Structured programming is a kind of imperative programming where the control flow is defined by nested loops,
conditionals, and subroutines, rather than via gotos. Variables are generally local to blocks (have lexical scope).
Eg:- Algol 60, PL/I, Algol 68, Pascal, C, Ada 83, Modula, Modula-2.
Object Oriented Programming:
OOP is based on the sending of messages to objects. Objects respond to messages by performing operations.
Messages can have arguments, so "sending messages" looks a lot like calling subroutines.
Eg:- Simula-67; Smalltalk, C++, CLOS (object system of Common Lisp), Eiffel, Modula-3, Ada 95, Java, C#,
Ruby.
Declarative Programming:
Control flow in declarative programming is implicit: the programmer states only what the result should look like,
not how to obtain it. No loops, no assignments, etc.
Functional Programming:
In functional programming control flow is expressed by combining function calls, rather than by assigning
values to variables.
Logic and Constraint Programming:
Logic and constraint programming are two paradigms in which programs are built by setting up relations that
specify facts and inference rules, and asking whether or not something is true (i.e. specifying a goal.)
Unification and backtracking to find solutions (i.e. satisfy goals) takes place automatically.
Eg:- Prolog, GHC, Parlog, Vulcan, Polka, Mercury, Fnil.
Procedural Programming:
Procedural programming uses a list of instructions to tell the computer what to do step-by-step. A procedure
contains a series of computational steps to be carried out. Procedural programming is also referred to as
imperative programming. Procedural programming languages are also known as top-down languages.
Eg:- Fortran, COBOL and C
Introduction to Oops
Object oriented programming is an approach that provides a way of modularizing programs by creating
partitioned memory area for both data and functions that can be used as templates for creating copies of such
modules on demand.
OOP is a way of organizing programs and data. The languages such as Java, C++, small talk, Ada support
OOP features.
OOPS ties data more closely to the functions that operate on it and protects it from unintentional
modification by other functions. OOPS allows us to decompose a problem into a number of entities called
objects and then build data and methods around these entities. The combination of data and methods make up an
object.
Features of object-oriented paradigm:
1.Concentrate on data rather than
procedure.
2.Programs are divided into objects.
3.Data structures are designed to
characterize the objects.
5. Methods and data of an object are together in
the data structure
6. data is hidden and cannot be accessed by
external functions
7. Objects may communicates with each other
through methods
8. New data and methods can be easily added
using bottom-up approach
Basic concepts of Object-oriented programming
1.1.2.1 Classes:
A class is a collection of variables and methods that an object can have or it is a template or model for
building objects.
1.1.2.2 Objects
An object is an instance of a class. The methods are the gateways to access data. The methods and data are
grouped together and placed in a container called object. The instances are the concrete representation of a class or
object. A class can have many instances.
1.1.2.3 Data Abstraction
It refers to the act of representing essential features without including the background details.
For example to define a particular object we need not know all the things about that object. To define
student we can have data like Roll no, Name, marks etc. We need not have his color, weight etc. OOPs uses
data abstraction feature to put the abstract attributes and methods that operate on these attributes.
1.1.2.4 Data Encapsulation
The wrapping up of data and method into a single unit (called Class) is known as encapsulation. The data is not
accessible to the outside world and only those methods which are wrapped in the class, can access it. These methods
provide the interface between the objects data and the program. This insulation of the data from direct access by the
program is called data hiding.
1.1.2.5 Inheritance :
It is the process by which objects of one class gets the properties of objects of another class.
The class whose property is being inherited by another class is called base class. The class that inherits a
particular property or a set of properties from the base class is called derived class.
The concept of inheritance provides the idea of reusability. This means we can add additional features to an
existing class without modifying it .This possible by deriving a new class from the existing one. The new class
will have the combined features of both the class. In java the derived class is known as subclass.
1.1.2.6 Polymorphism:
It means the ability to take more than one form. The operation may exhibit different behavior in
different instances. The behavior depends upon the types of data used in operation.
For example, consider the operation of addition. For two numbers, the operation will generate a sum. If the
operands are strings, then the operation would produce a third string by concatenation.
1.1.2.7 Dynamic binding:
Binding refers to the linking of a procedure call to the code to be executed.
In response to the call, dynamic binding means that the code associated with a given procedure call is not known
until the time of the call that the run time. It is associated with polymorphism and inheritance. A procedure call
associated with a polymorphism reference depends on the dynamic types of that reference.
1.1.2.8 Message communication:
An object oriented program consists of a set of object that communicate with each other.
Communication involves the following steps.
1. Creating classes.
2. Creating object from classes definition.
3. Establishing communication among objects.
Objects communicate with one another by sending and receiving information much the same way as people pass
messages to one another
A message for an object is a request for execution of a procedure and therefore will invoke a method
(procedure) in receiving object that generates the desired result. The message passing involves specifying, the
name of the object, the name of the method and the information to be sent.
Example:
Employee . salary (name)
Objects have a life cycle. They can be created and destroyed. Communication with an object is feasible as long as it
is alive.
1.1.3 Benefits of OOPS
1. Repetition of codes is avoided by implementing inheritance.
2. Better quality of software.
3. security of data by the principle data hiding.
4. multiple objects can coexist without any interference.
5. objects in the problem domain can be mapped to those objects in the program.
6. it is easy to partition the work in the project.
7. Upgrading programs is easy.
8. complexity of the software is reduced.
9. Better communication between the objects.
1.1.4 Application of OOPS
1. Real-time systems
2. Simulation and modeling
3. Object oriented data bases
4. Hypertext, hyper media and expertext.
5. Artificial intelligence and expert systems.
6. Neural networks and parallel programming.
7. decision support and office automation systems.
8. CAD/CAM system.
1.2.1 History of Java
Java is a general purpose; object oriented programming language developed by SUN micro Systems of USA.
sun micro Systems decided to develop special S/W that could be used to manipulate consumer
electronic devices like TVs, VCRs and toasters. A team of programmers headed by James
Gosling known as Green project team was formed to undertake the task. The team found that
oop’s like C and C++ had limitations in reliability and portability. So, they designed a new
language known as oak, which is simple, reliable and portable. The oak controlled the home
appliances using a hand held device with a touch sensitive screen.
the World Wide Web (www) appeared on the Internet. The green project team developed web
applets using oak, which can be run on all types of computers, connected to the Internet.
the team developed a web browser called Hot Java, which can be used to locate and run applet
programs on Internet. Thus, oak became popular.
, due to legal snags, oak was renamed as Java and companies like Netscape and Microsoft
supported it.
Java became the leader of Internet programming as well as a general purpose object oriented
language. Java is a platform-neutral language. It is the first programming language that is not
tied to any particular h/w or OS.
1.2.2 Java features (Characteristics of Java)
1) Compiled and Interpreted:
Java is a two stage System. First the Java compiler translates the source code into byte code
instructions. This can be interpreted on any System that has a proper Java runtime on it. In the
second stage, the Java interpreter generates machine code that can be executed by the machine that is
running the Java program. Thus, Java is both a compiled and interpreted language.
2) Platform Independent and portable
Java is a platform independent language. Java programs can be easily ported from one computer
System to the other. Any change or upgradation in OS, processors and System resources will not
affect Java programs.
Java ensures portability in two ways. First, the Java compiler generates byte code instructions
which can be implemented on any machine. Second, the size of the primitive data types is
machine independent.
3) Object oriented
Java is a pure OOP language. Everything in Java is an object. All program code & data reside
within objects and classes. Java has an extensive set of classes, arranged in packages which can be
used in user programs by inheritance. The object model is simple and can be extended easily.
1.2.2 Java features (Characteristics of Java)
4) Robust and Secure
Java is a robust language. It ensures reliable code. It checks code as we write it and again before
running it. Java is a garbage collected language. Hence, the programmers need not worry about
memory management problems. Java can handle exceptions and can catch even serious errors.
Thus, it eliminates the risk of crashing the System.
5) Distributed
Java is designed as a distributed language for creating applications on networks. It can share both
data & programs. Java applications can open and access remote objects on Internet easily as they
can do in a local System. Hence, multiple programmers at multiple remote locations can
collaborate and work together on a single project.
6) Simple, small and Familiar
Java is a small language. It is also simple to learn and write. Java doesn’t use concepts like
pointers, preprocessors, header files, go to statement. It also eliminates operator overloading and
multiple inheritance.
Java is a familiar language since the Java code looks like C++ code.
1.2.2 Java features (Characteristics of Java)
7)Multithreaded and Interactive
Java supports multithreaded programs, which can handle multiple tasks simultaneously. For
example, we can listen to an audio clip while scrolling a page. Also at the same time, we can
download an applet from a distant computer.
Java runtime comes with tools that support multiprocess synchronization and thus we can easily
construct smoothly running interactive Systems.
8) High performance
Java speed is comparable to that of C++ Java architecture has been designed in such a way that
overheads are reduced during runtime. The multithreading feature helps to enhance the overall
executing speed of Java programs.
9) Dynamic and Extensible
Java is a dynamic language capable of linking new class libraries, methods and objects to it. We
can also determine the type of a class through a query. Depending upon the response, we can
either link it dynamically or abort the program.
Java functions support native methods which are nothing but programs written in languages like C
and C++. The native methods are linked dynamically at run time.
1.2.3 Java environment
Java environment consists of the following
i) Java Development Kit (JDK)
ii) Application Programming interface called API (or)
Java Standard Library (JSL)
1.2.3.1 jdk:
Java Development kit comes with a collection of tools that are used for developing and running Java programs.
1) appletViewer: It enables us to run Java applets.
2) java: It is an interpreter. It runs applets and applications by reading and interpreting byte code files.
3) Javac: It is the complier used to translate source code into byte code.
4) Javadoc: It creates the HTML format documentation from the Java source code files.
5) javah: It produces header files for use with native methods.
6) javap: It is the java disassembler that converts the byte code files into a program description.
7) jdb: It is the java debugger used to locate errors in a program.
1.2.3.2 API:
This contains no. of classes and methods for writing application programs. The commonly used packages are
1 ) Language Support package: A collection of classes and methods for implementing basic features
2) Utilities package: A collection of classes to provide utility functions such as date and time
3) Applet package: A collection of classes used to create applets.
4) Abstract window: A collection of classes used to implement GUI.
5) Input / Output package: A collection of classes used for input/ output manipulation.
1.3 Introduction to Java
1.3.1 Types of Javaprograms
1.Stand alone applications
These are programs written to carry
out certain tasks on a stand alone local
computer. For executing such
programs, first the source code is
compiled into byte code using complier
and then the byte code is executed
using interpreter.
2.Web applets
These are small programs developed for Internet
applications. An applet located on a distant
computer (server) can be downloaded through
Internet and executed on a local computer (client)
using a Java compatible browser. Applets can be
developed for simple animated graphics to complex
games and utilities. Creating and running applets
are more complex since they are embedded in a
HTML document and run inside a web page.
1.3.2 Creating & executing a Java program
Application programs are created and executed as follows.
A source code file is created using a text editor
It is then compiled using the compiler javac to produce byte code
and executed using interpreter java.
The debugger jdb finds errors in source code. javap is a disassembler
used to convert the byte code back into source code.
Character set
graphic <= alphanumeric | special
alphanumeric <= alphabetic | numeric
alphabetic <= lower-case | upper-case
lower-case <=a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z
upper-case <=A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z
numeric <=0|1|2|3|4|5|6|7|8|9
special <= !|%|^|&|*|(|)|-|+|=|{|}|||~|[|]||;|'|:|"|<|>|?|,|.|/|#|@|`|_
1.3.3 Java tokens:
The smallest units of Java language are the characters used to write Java tokens. These characters are defined
by the Unicode character set. Java language includes five types of tokens and they are:
 Reserved Keywords
 Identifiers
 Literals
 Operators
 Separators
1.3.3.1 Key words
Reserved keywords are special identifiers that form part of a language definition. They are used to
identify built-in-types, modifiers and mechanisms for flow control. The keywords combined with operators
and separators according to a syntax form definition of the Java language. The keywords cannot be used as
names for variables, classes, methods and so on. There are 60 reserved words available. They should be
written only in lower case letters. They are
abstract boolean break byte byValue case
cast catch char class const continue
default do double else extends false
final finally float for future generic
goto if implements import inner instanceOf
int interface long native new null
operator outer package private protected public
rest return short static super switch
synchronized this threadSafe throw throws transient
true try var void volatile while
1.3.3.2 Identifiers
Identifiers are used by programmers to name things in Java: things such as variables, methods, fields, classes,
interfaces, exceptions, packages, etc.
 All identifiers must start with either a letter( a to z or A to Z ) or currency character($) or an underscore.
 After the first character, an identifier can have any combination of characters.
 A Java keyword cannot be used as an identifier.
 Identifiers in Java are case sensitive, foo and Foo are two different identifiers.
1.3.3.3 Literals
All constant values written in a program are literals.
Types of literals
 Integer literal
 floating-point literal
 Boolean literal
 Character literal
 String literal
 Null literal
Literal Type
1 Int
3.14 double (1. is a double too)
True boolean
'3' char ('P' and '+' are char too)
"CMU ID" String
Null any reference type
Here are some examples of literals of each of
these types.
1.3.3.4 Separators (also known as a punctuators)
There are nine, single character separators in Java
; , . ( ) { } [ ]
1.3.4 Java virtual machine(JVM):
All language compilers translate source code into machine code for a specific computer. But java compiler produces
an intermediate code known as byte code for a machine that does not exist. This machine is called the java virtual
machine and it exists only inside the computer memory. The process of compiling a java program into byte code
which is also referred to as virtual machine code. The virtual machine code is not machine specific. The machine
specific code known as machine code is called generated by the java interpreter.
1.3.5 Command line arguments:
Sometimes, we may like our programs to act in a particular way depending on the i/p given at the time of
execution. This is achieved using command line arguments. Command line arguments are parameters that are
supplied to the program at the time of invoking it for execution.
Eg;-
class Comlinetest
{
public static void main (String args [])
{
int count, i=0;
String s;
count =args.length;
System.out.println (“No. of arguments =”+count);
while (i<count)
{
s=args [i];
i=i+1;
System.out.println (i+”:”+”java is”+s);
}}}
Compile using
javac comlinetest.java
Run using
java comlinetest simple object_oriented distributed robust secure
o/p
No. of arguments =5
1. java is simple
2. java is object oriented
3. java is distributed
4. java is robust
java is secure
The command line arguments are passed to the program through the array args. The
command line has 5 arguments. They are assigned to the array args as follows
args[0] =”simple”
args[1] = “object. oriented”
args[2] = “distributed”
args[3] = “robust”
args[4] = “secure”
o/p
No. of arguments =5
1. java is simple
2. java is object oriented
3. java is distributed
4. java is robust
5. java is secure1.3.6 Comments in Java Program:
The comment lines give the name of the program, author and other details like why and what of classes and
how of algorithms. Comments help to maintain the program.
1. Single line comment
The comment is written beginning with 
Eg: -  sample program
2. Multiline comment
This comment is written beginning with /* and ending with */
Eg: - /* sample program
Written on 25-5-04*/
3. Documentation comment
It is used for generating documentation automatically beginning with /** and ending with * /
INTRODUCTION TO JAVA

More Related Content

What's hot

OOP Java
OOP JavaOOP Java
OOP Java
Saif Kassim
 
Object-Oriented Concepts
Object-Oriented ConceptsObject-Oriented Concepts
Object-Oriented ConceptsAbdalla Mahmoud
 
OOP - Benefits and advantages of OOP
OOP - Benefits and advantages of OOPOOP - Benefits and advantages of OOP
OOP - Benefits and advantages of OOP
Mudasir Qazi
 
Fundamentals of JAVA
Fundamentals of JAVAFundamentals of JAVA
Fundamentals of JAVA
Swapnika Godbole
 
Introduction of java
Introduction  of javaIntroduction  of java
Introduction of java
Madishetty Prathibha
 
Java features
Java  features Java  features
Java features
Madishetty Prathibha
 
OCR processing with deep learning: Apply to Vietnamese documents
OCR processing with deep learning: Apply to Vietnamese documents OCR processing with deep learning: Apply to Vietnamese documents
OCR processing with deep learning: Apply to Vietnamese documents
Viet-Trung TRAN
 
Object Oriented Programming in Python
Object Oriented Programming in PythonObject Oriented Programming in Python
Object Oriented Programming in Python
Jordi Vilaplana
 
Class notes(week 2) on basic concepts of oop-2
Class notes(week 2) on basic concepts of oop-2Class notes(week 2) on basic concepts of oop-2
Class notes(week 2) on basic concepts of oop-2
Kuntal Bhowmick
 
Class notes(week 2) on basic concepts of oop-2
Class notes(week 2) on basic concepts of oop-2Class notes(week 2) on basic concepts of oop-2
Class notes(week 2) on basic concepts of oop-2
Kuntal Bhowmick
 
1 Intro Object Oriented Programming
1  Intro Object Oriented Programming1  Intro Object Oriented Programming
1 Intro Object Oriented Programming
Docent Education
 
Language Identifier for Languages of Pakistan Including Arabic and Persian
Language Identifier for Languages of Pakistan Including Arabic and PersianLanguage Identifier for Languages of Pakistan Including Arabic and Persian
Language Identifier for Languages of Pakistan Including Arabic and Persian
Waqas Tariq
 
Object Oriented Approach Within Siebel Boundaries
Object Oriented Approach Within Siebel BoundariesObject Oriented Approach Within Siebel Boundaries
Object Oriented Approach Within Siebel BoundariesRoman Agaev
 
Object oriented programming
Object oriented programmingObject oriented programming
JAVA
JAVAJAVA
Memory models in c#
Memory models in c#Memory models in c#
Memory models in c#
Sophie Obomighie
 
Word Format.doc
Word Format.docWord Format.doc
Word Format.docbutest
 
A Portable Approach for Bidirectional Integration between a Logic and a Stati...
A Portable Approach for Bidirectional Integration between a Logic and a Stati...A Portable Approach for Bidirectional Integration between a Logic and a Stati...
A Portable Approach for Bidirectional Integration between a Logic and a Stati...
Sergio Castro
 
A Dialogue System for Telugu, a Resource-Poor Language
A Dialogue System for Telugu, a Resource-Poor LanguageA Dialogue System for Telugu, a Resource-Poor Language
A Dialogue System for Telugu, a Resource-Poor LanguageSravanthi Mullapudi
 
OBJECT ORIENTED ROGRAMMING With Question And Answer Full
OBJECT ORIENTED ROGRAMMING With Question And Answer  FullOBJECT ORIENTED ROGRAMMING With Question And Answer  Full
OBJECT ORIENTED ROGRAMMING With Question And Answer Full
Manas Rai
 

What's hot (20)

OOP Java
OOP JavaOOP Java
OOP Java
 
Object-Oriented Concepts
Object-Oriented ConceptsObject-Oriented Concepts
Object-Oriented Concepts
 
OOP - Benefits and advantages of OOP
OOP - Benefits and advantages of OOPOOP - Benefits and advantages of OOP
OOP - Benefits and advantages of OOP
 
Fundamentals of JAVA
Fundamentals of JAVAFundamentals of JAVA
Fundamentals of JAVA
 
Introduction of java
Introduction  of javaIntroduction  of java
Introduction of java
 
Java features
Java  features Java  features
Java features
 
OCR processing with deep learning: Apply to Vietnamese documents
OCR processing with deep learning: Apply to Vietnamese documents OCR processing with deep learning: Apply to Vietnamese documents
OCR processing with deep learning: Apply to Vietnamese documents
 
Object Oriented Programming in Python
Object Oriented Programming in PythonObject Oriented Programming in Python
Object Oriented Programming in Python
 
Class notes(week 2) on basic concepts of oop-2
Class notes(week 2) on basic concepts of oop-2Class notes(week 2) on basic concepts of oop-2
Class notes(week 2) on basic concepts of oop-2
 
Class notes(week 2) on basic concepts of oop-2
Class notes(week 2) on basic concepts of oop-2Class notes(week 2) on basic concepts of oop-2
Class notes(week 2) on basic concepts of oop-2
 
1 Intro Object Oriented Programming
1  Intro Object Oriented Programming1  Intro Object Oriented Programming
1 Intro Object Oriented Programming
 
Language Identifier for Languages of Pakistan Including Arabic and Persian
Language Identifier for Languages of Pakistan Including Arabic and PersianLanguage Identifier for Languages of Pakistan Including Arabic and Persian
Language Identifier for Languages of Pakistan Including Arabic and Persian
 
Object Oriented Approach Within Siebel Boundaries
Object Oriented Approach Within Siebel BoundariesObject Oriented Approach Within Siebel Boundaries
Object Oriented Approach Within Siebel Boundaries
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
JAVA
JAVAJAVA
JAVA
 
Memory models in c#
Memory models in c#Memory models in c#
Memory models in c#
 
Word Format.doc
Word Format.docWord Format.doc
Word Format.doc
 
A Portable Approach for Bidirectional Integration between a Logic and a Stati...
A Portable Approach for Bidirectional Integration between a Logic and a Stati...A Portable Approach for Bidirectional Integration between a Logic and a Stati...
A Portable Approach for Bidirectional Integration between a Logic and a Stati...
 
A Dialogue System for Telugu, a Resource-Poor Language
A Dialogue System for Telugu, a Resource-Poor LanguageA Dialogue System for Telugu, a Resource-Poor Language
A Dialogue System for Telugu, a Resource-Poor Language
 
OBJECT ORIENTED ROGRAMMING With Question And Answer Full
OBJECT ORIENTED ROGRAMMING With Question And Answer  FullOBJECT ORIENTED ROGRAMMING With Question And Answer  Full
OBJECT ORIENTED ROGRAMMING With Question And Answer Full
 

Similar to INTRODUCTION TO JAVA

chapter - 1.ppt
chapter - 1.pptchapter - 1.ppt
chapter - 1.ppt
SakthiVinoth78
 
POP vs OOP Introduction
POP vs OOP IntroductionPOP vs OOP Introduction
POP vs OOP Introduction
Hashni T
 
MCA NOTES.pdf
MCA NOTES.pdfMCA NOTES.pdf
MCA NOTES.pdf
RAJASEKHARV10
 
Oops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts in JavaOops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts in Java
Madishetty Prathibha
 
OOPS_Unit_1
OOPS_Unit_1OOPS_Unit_1
OOPS_Unit_1
Shipra Swati
 
Java notes jkuat it
Java notes jkuat itJava notes jkuat it
Java notes jkuat it
Arc Keepers Solutions
 
Java_presesntation.ppt
Java_presesntation.pptJava_presesntation.ppt
Java_presesntation.ppt
VGaneshKarthikeyan
 
OOP ppt.pdf
OOP ppt.pdfOOP ppt.pdf
OOP ppt.pdf
ArpitaJana28
 
OOP.pptx
OOP.pptxOOP.pptx
OOP.pptx
kalyanibedekar
 
Unit1 jaava
Unit1 jaavaUnit1 jaava
Unit1 jaavamrecedu
 
M.c.a. (sem iv)- java programming
M.c.a. (sem   iv)- java programmingM.c.a. (sem   iv)- java programming
M.c.a. (sem iv)- java programming
Praveen Chowdary
 
Object Oriented Language
Object Oriented LanguageObject Oriented Language
Object Oriented Languagedheva B
 
Block_1_Unit- I.pdf bca learning for exam you
Block_1_Unit- I.pdf  bca learning  for exam youBlock_1_Unit- I.pdf  bca learning  for exam you
Block_1_Unit- I.pdf bca learning for exam you
vosawe9128
 
Unit 1 OOSE
Unit 1 OOSE Unit 1 OOSE
Unit 1 OOSE
ChhayaShelake
 
Object Oriented Programming using C++.pptx
Object Oriented Programming using C++.pptxObject Oriented Programming using C++.pptx
Object Oriented Programming using C++.pptx
parveen837153
 
Bca 2nd sem u-1 iintroduction
Bca 2nd sem u-1 iintroductionBca 2nd sem u-1 iintroduction
Bca 2nd sem u-1 iintroduction
Rai University
 
Mca 2 sem u-1 iintroduction
Mca 2 sem u-1 iintroductionMca 2 sem u-1 iintroduction
Mca 2 sem u-1 iintroduction
Rai University
 
1 intro
1 intro1 intro
1 intro
abha48
 

Similar to INTRODUCTION TO JAVA (20)

chapter - 1.ppt
chapter - 1.pptchapter - 1.ppt
chapter - 1.ppt
 
POP vs OOP Introduction
POP vs OOP IntroductionPOP vs OOP Introduction
POP vs OOP Introduction
 
MCA NOTES.pdf
MCA NOTES.pdfMCA NOTES.pdf
MCA NOTES.pdf
 
Oops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts in JavaOops concepts || Object Oriented Programming Concepts in Java
Oops concepts || Object Oriented Programming Concepts in Java
 
OOPS_Unit_1
OOPS_Unit_1OOPS_Unit_1
OOPS_Unit_1
 
Java chapter 3
Java   chapter 3Java   chapter 3
Java chapter 3
 
Java notes jkuat it
Java notes jkuat itJava notes jkuat it
Java notes jkuat it
 
Java notes(OOP) jkuat IT esection
Java notes(OOP) jkuat IT esectionJava notes(OOP) jkuat IT esection
Java notes(OOP) jkuat IT esection
 
Java_presesntation.ppt
Java_presesntation.pptJava_presesntation.ppt
Java_presesntation.ppt
 
OOP ppt.pdf
OOP ppt.pdfOOP ppt.pdf
OOP ppt.pdf
 
OOP.pptx
OOP.pptxOOP.pptx
OOP.pptx
 
Unit1 jaava
Unit1 jaavaUnit1 jaava
Unit1 jaava
 
M.c.a. (sem iv)- java programming
M.c.a. (sem   iv)- java programmingM.c.a. (sem   iv)- java programming
M.c.a. (sem iv)- java programming
 
Object Oriented Language
Object Oriented LanguageObject Oriented Language
Object Oriented Language
 
Block_1_Unit- I.pdf bca learning for exam you
Block_1_Unit- I.pdf  bca learning  for exam youBlock_1_Unit- I.pdf  bca learning  for exam you
Block_1_Unit- I.pdf bca learning for exam you
 
Unit 1 OOSE
Unit 1 OOSE Unit 1 OOSE
Unit 1 OOSE
 
Object Oriented Programming using C++.pptx
Object Oriented Programming using C++.pptxObject Oriented Programming using C++.pptx
Object Oriented Programming using C++.pptx
 
Bca 2nd sem u-1 iintroduction
Bca 2nd sem u-1 iintroductionBca 2nd sem u-1 iintroduction
Bca 2nd sem u-1 iintroduction
 
Mca 2 sem u-1 iintroduction
Mca 2 sem u-1 iintroductionMca 2 sem u-1 iintroduction
Mca 2 sem u-1 iintroduction
 
1 intro
1 intro1 intro
1 intro
 

Recently uploaded

Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
Celine George
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
Celine George
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
PedroFerreira53928
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
Celine George
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
EverAndrsGuerraGuerr
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
PedroFerreira53928
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
GeoBlogs
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
Col Mukteshwar Prasad
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
Ashokrao Mane college of Pharmacy Peth-Vadgaon
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
TechSoup
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
Jisc
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
DeeptiGupta154
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
Jheel Barad
 

Recently uploaded (20)

Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
How to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERPHow to Create Map Views in the Odoo 17 ERP
How to Create Map Views in the Odoo 17 ERP
 
How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17How to Make a Field invisible in Odoo 17
How to Make a Field invisible in Odoo 17
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
Thesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.pptThesis Statement for students diagnonsed withADHD.ppt
Thesis Statement for students diagnonsed withADHD.ppt
 
Basic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumersBasic phrases for greeting and assisting costumers
Basic phrases for greeting and assisting costumers
 
Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......Ethnobotany and Ethnopharmacology ......
Ethnobotany and Ethnopharmacology ......
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup   New Member Orientation and Q&A (May 2024).pdfWelcome to TechSoup   New Member Orientation and Q&A (May 2024).pdf
Welcome to TechSoup New Member Orientation and Q&A (May 2024).pdf
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
Supporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptxSupporting (UKRI) OA monographs at Salford.pptx
Supporting (UKRI) OA monographs at Salford.pptx
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Overview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with MechanismOverview on Edible Vaccine: Pros & Cons with Mechanism
Overview on Edible Vaccine: Pros & Cons with Mechanism
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
Instructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptxInstructions for Submissions thorugh G- Classroom.pptx
Instructions for Submissions thorugh G- Classroom.pptx
 

INTRODUCTION TO JAVA

  • 1. INTRODUCTIONTO OOPS Object Oriented Programming with JAVA Mr. RAMALINGHAM KRISHNAMOORTHY, ME., LECTURER/COMPUTER ENGINEERING DEPARTMENT, V.S.V.N POLYTECHNIC COLLEGE, (VIRUDHUNAGARS.VELLAICHAMY NADAR POLYTECHNICCOLLEGE) VIRUDHUNAGAR
  • 2. Paradigms of Programming Languages A programming paradigm is a style or “way” of programming. Some languages make it easy to write in some paradigms but not others.
  • 3. List of Common Paradigms Imperative Programming: Control flow in imperative programming is explicit: commands show how the computation takes place, step by step. Each step affects the global state of the computation. Structured Programming: Structured programming is a kind of imperative programming where the control flow is defined by nested loops, conditionals, and subroutines, rather than via gotos. Variables are generally local to blocks (have lexical scope). Eg:- Algol 60, PL/I, Algol 68, Pascal, C, Ada 83, Modula, Modula-2. Object Oriented Programming: OOP is based on the sending of messages to objects. Objects respond to messages by performing operations. Messages can have arguments, so "sending messages" looks a lot like calling subroutines. Eg:- Simula-67; Smalltalk, C++, CLOS (object system of Common Lisp), Eiffel, Modula-3, Ada 95, Java, C#, Ruby. Declarative Programming: Control flow in declarative programming is implicit: the programmer states only what the result should look like, not how to obtain it. No loops, no assignments, etc. Functional Programming: In functional programming control flow is expressed by combining function calls, rather than by assigning values to variables.
  • 4. Logic and Constraint Programming: Logic and constraint programming are two paradigms in which programs are built by setting up relations that specify facts and inference rules, and asking whether or not something is true (i.e. specifying a goal.) Unification and backtracking to find solutions (i.e. satisfy goals) takes place automatically. Eg:- Prolog, GHC, Parlog, Vulcan, Polka, Mercury, Fnil. Procedural Programming: Procedural programming uses a list of instructions to tell the computer what to do step-by-step. A procedure contains a series of computational steps to be carried out. Procedural programming is also referred to as imperative programming. Procedural programming languages are also known as top-down languages. Eg:- Fortran, COBOL and C
  • 5. Introduction to Oops Object oriented programming is an approach that provides a way of modularizing programs by creating partitioned memory area for both data and functions that can be used as templates for creating copies of such modules on demand. OOP is a way of organizing programs and data. The languages such as Java, C++, small talk, Ada support OOP features. OOPS ties data more closely to the functions that operate on it and protects it from unintentional modification by other functions. OOPS allows us to decompose a problem into a number of entities called objects and then build data and methods around these entities. The combination of data and methods make up an object. Features of object-oriented paradigm: 1.Concentrate on data rather than procedure. 2.Programs are divided into objects. 3.Data structures are designed to characterize the objects. 5. Methods and data of an object are together in the data structure 6. data is hidden and cannot be accessed by external functions 7. Objects may communicates with each other through methods 8. New data and methods can be easily added using bottom-up approach
  • 6. Basic concepts of Object-oriented programming 1.1.2.1 Classes: A class is a collection of variables and methods that an object can have or it is a template or model for building objects.
  • 7. 1.1.2.2 Objects An object is an instance of a class. The methods are the gateways to access data. The methods and data are grouped together and placed in a container called object. The instances are the concrete representation of a class or object. A class can have many instances.
  • 8. 1.1.2.3 Data Abstraction It refers to the act of representing essential features without including the background details. For example to define a particular object we need not know all the things about that object. To define student we can have data like Roll no, Name, marks etc. We need not have his color, weight etc. OOPs uses data abstraction feature to put the abstract attributes and methods that operate on these attributes. 1.1.2.4 Data Encapsulation The wrapping up of data and method into a single unit (called Class) is known as encapsulation. The data is not accessible to the outside world and only those methods which are wrapped in the class, can access it. These methods provide the interface between the objects data and the program. This insulation of the data from direct access by the program is called data hiding.
  • 9. 1.1.2.5 Inheritance : It is the process by which objects of one class gets the properties of objects of another class. The class whose property is being inherited by another class is called base class. The class that inherits a particular property or a set of properties from the base class is called derived class. The concept of inheritance provides the idea of reusability. This means we can add additional features to an existing class without modifying it .This possible by deriving a new class from the existing one. The new class will have the combined features of both the class. In java the derived class is known as subclass.
  • 10. 1.1.2.6 Polymorphism: It means the ability to take more than one form. The operation may exhibit different behavior in different instances. The behavior depends upon the types of data used in operation. For example, consider the operation of addition. For two numbers, the operation will generate a sum. If the operands are strings, then the operation would produce a third string by concatenation. 1.1.2.7 Dynamic binding: Binding refers to the linking of a procedure call to the code to be executed. In response to the call, dynamic binding means that the code associated with a given procedure call is not known until the time of the call that the run time. It is associated with polymorphism and inheritance. A procedure call associated with a polymorphism reference depends on the dynamic types of that reference.
  • 11. 1.1.2.8 Message communication: An object oriented program consists of a set of object that communicate with each other. Communication involves the following steps. 1. Creating classes. 2. Creating object from classes definition. 3. Establishing communication among objects. Objects communicate with one another by sending and receiving information much the same way as people pass messages to one another A message for an object is a request for execution of a procedure and therefore will invoke a method (procedure) in receiving object that generates the desired result. The message passing involves specifying, the name of the object, the name of the method and the information to be sent.
  • 12. Example: Employee . salary (name) Objects have a life cycle. They can be created and destroyed. Communication with an object is feasible as long as it is alive.
  • 13. 1.1.3 Benefits of OOPS 1. Repetition of codes is avoided by implementing inheritance. 2. Better quality of software. 3. security of data by the principle data hiding. 4. multiple objects can coexist without any interference. 5. objects in the problem domain can be mapped to those objects in the program. 6. it is easy to partition the work in the project. 7. Upgrading programs is easy. 8. complexity of the software is reduced. 9. Better communication between the objects. 1.1.4 Application of OOPS 1. Real-time systems 2. Simulation and modeling 3. Object oriented data bases 4. Hypertext, hyper media and expertext. 5. Artificial intelligence and expert systems. 6. Neural networks and parallel programming. 7. decision support and office automation systems. 8. CAD/CAM system.
  • 14. 1.2.1 History of Java Java is a general purpose; object oriented programming language developed by SUN micro Systems of USA. sun micro Systems decided to develop special S/W that could be used to manipulate consumer electronic devices like TVs, VCRs and toasters. A team of programmers headed by James Gosling known as Green project team was formed to undertake the task. The team found that oop’s like C and C++ had limitations in reliability and portability. So, they designed a new language known as oak, which is simple, reliable and portable. The oak controlled the home appliances using a hand held device with a touch sensitive screen. the World Wide Web (www) appeared on the Internet. The green project team developed web applets using oak, which can be run on all types of computers, connected to the Internet. the team developed a web browser called Hot Java, which can be used to locate and run applet programs on Internet. Thus, oak became popular. , due to legal snags, oak was renamed as Java and companies like Netscape and Microsoft supported it. Java became the leader of Internet programming as well as a general purpose object oriented language. Java is a platform-neutral language. It is the first programming language that is not tied to any particular h/w or OS.
  • 15. 1.2.2 Java features (Characteristics of Java) 1) Compiled and Interpreted: Java is a two stage System. First the Java compiler translates the source code into byte code instructions. This can be interpreted on any System that has a proper Java runtime on it. In the second stage, the Java interpreter generates machine code that can be executed by the machine that is running the Java program. Thus, Java is both a compiled and interpreted language. 2) Platform Independent and portable Java is a platform independent language. Java programs can be easily ported from one computer System to the other. Any change or upgradation in OS, processors and System resources will not affect Java programs. Java ensures portability in two ways. First, the Java compiler generates byte code instructions which can be implemented on any machine. Second, the size of the primitive data types is machine independent. 3) Object oriented Java is a pure OOP language. Everything in Java is an object. All program code & data reside within objects and classes. Java has an extensive set of classes, arranged in packages which can be used in user programs by inheritance. The object model is simple and can be extended easily.
  • 16. 1.2.2 Java features (Characteristics of Java) 4) Robust and Secure Java is a robust language. It ensures reliable code. It checks code as we write it and again before running it. Java is a garbage collected language. Hence, the programmers need not worry about memory management problems. Java can handle exceptions and can catch even serious errors. Thus, it eliminates the risk of crashing the System. 5) Distributed Java is designed as a distributed language for creating applications on networks. It can share both data & programs. Java applications can open and access remote objects on Internet easily as they can do in a local System. Hence, multiple programmers at multiple remote locations can collaborate and work together on a single project. 6) Simple, small and Familiar Java is a small language. It is also simple to learn and write. Java doesn’t use concepts like pointers, preprocessors, header files, go to statement. It also eliminates operator overloading and multiple inheritance. Java is a familiar language since the Java code looks like C++ code.
  • 17. 1.2.2 Java features (Characteristics of Java) 7)Multithreaded and Interactive Java supports multithreaded programs, which can handle multiple tasks simultaneously. For example, we can listen to an audio clip while scrolling a page. Also at the same time, we can download an applet from a distant computer. Java runtime comes with tools that support multiprocess synchronization and thus we can easily construct smoothly running interactive Systems. 8) High performance Java speed is comparable to that of C++ Java architecture has been designed in such a way that overheads are reduced during runtime. The multithreading feature helps to enhance the overall executing speed of Java programs. 9) Dynamic and Extensible Java is a dynamic language capable of linking new class libraries, methods and objects to it. We can also determine the type of a class through a query. Depending upon the response, we can either link it dynamically or abort the program. Java functions support native methods which are nothing but programs written in languages like C and C++. The native methods are linked dynamically at run time.
  • 18. 1.2.3 Java environment Java environment consists of the following i) Java Development Kit (JDK) ii) Application Programming interface called API (or) Java Standard Library (JSL)
  • 19. 1.2.3.1 jdk: Java Development kit comes with a collection of tools that are used for developing and running Java programs. 1) appletViewer: It enables us to run Java applets. 2) java: It is an interpreter. It runs applets and applications by reading and interpreting byte code files. 3) Javac: It is the complier used to translate source code into byte code. 4) Javadoc: It creates the HTML format documentation from the Java source code files. 5) javah: It produces header files for use with native methods. 6) javap: It is the java disassembler that converts the byte code files into a program description. 7) jdb: It is the java debugger used to locate errors in a program. 1.2.3.2 API: This contains no. of classes and methods for writing application programs. The commonly used packages are 1 ) Language Support package: A collection of classes and methods for implementing basic features 2) Utilities package: A collection of classes to provide utility functions such as date and time 3) Applet package: A collection of classes used to create applets. 4) Abstract window: A collection of classes used to implement GUI. 5) Input / Output package: A collection of classes used for input/ output manipulation.
  • 20. 1.3 Introduction to Java 1.3.1 Types of Javaprograms 1.Stand alone applications These are programs written to carry out certain tasks on a stand alone local computer. For executing such programs, first the source code is compiled into byte code using complier and then the byte code is executed using interpreter. 2.Web applets These are small programs developed for Internet applications. An applet located on a distant computer (server) can be downloaded through Internet and executed on a local computer (client) using a Java compatible browser. Applets can be developed for simple animated graphics to complex games and utilities. Creating and running applets are more complex since they are embedded in a HTML document and run inside a web page.
  • 21. 1.3.2 Creating & executing a Java program Application programs are created and executed as follows. A source code file is created using a text editor It is then compiled using the compiler javac to produce byte code and executed using interpreter java. The debugger jdb finds errors in source code. javap is a disassembler used to convert the byte code back into source code.
  • 22. Character set graphic <= alphanumeric | special alphanumeric <= alphabetic | numeric alphabetic <= lower-case | upper-case lower-case <=a|b|c|d|e|f|g|h|i|j|k|l|m|n|o|p|q|r|s|t|u|v|w|x|y|z upper-case <=A|B|C|D|E|F|G|H|I|J|K|L|M|N|O|P|Q|R|S|T|U|V|W|X|Y|Z numeric <=0|1|2|3|4|5|6|7|8|9 special <= !|%|^|&|*|(|)|-|+|=|{|}|||~|[|]||;|'|:|"|<|>|?|,|.|/|#|@|`|_ 1.3.3 Java tokens: The smallest units of Java language are the characters used to write Java tokens. These characters are defined by the Unicode character set. Java language includes five types of tokens and they are:  Reserved Keywords  Identifiers  Literals  Operators  Separators
  • 23. 1.3.3.1 Key words Reserved keywords are special identifiers that form part of a language definition. They are used to identify built-in-types, modifiers and mechanisms for flow control. The keywords combined with operators and separators according to a syntax form definition of the Java language. The keywords cannot be used as names for variables, classes, methods and so on. There are 60 reserved words available. They should be written only in lower case letters. They are abstract boolean break byte byValue case cast catch char class const continue default do double else extends false final finally float for future generic goto if implements import inner instanceOf int interface long native new null operator outer package private protected public rest return short static super switch synchronized this threadSafe throw throws transient true try var void volatile while
  • 24. 1.3.3.2 Identifiers Identifiers are used by programmers to name things in Java: things such as variables, methods, fields, classes, interfaces, exceptions, packages, etc.  All identifiers must start with either a letter( a to z or A to Z ) or currency character($) or an underscore.  After the first character, an identifier can have any combination of characters.  A Java keyword cannot be used as an identifier.  Identifiers in Java are case sensitive, foo and Foo are two different identifiers. 1.3.3.3 Literals All constant values written in a program are literals. Types of literals  Integer literal  floating-point literal  Boolean literal  Character literal  String literal  Null literal Literal Type 1 Int 3.14 double (1. is a double too) True boolean '3' char ('P' and '+' are char too) "CMU ID" String Null any reference type Here are some examples of literals of each of these types.
  • 25. 1.3.3.4 Separators (also known as a punctuators) There are nine, single character separators in Java ; , . ( ) { } [ ] 1.3.4 Java virtual machine(JVM): All language compilers translate source code into machine code for a specific computer. But java compiler produces an intermediate code known as byte code for a machine that does not exist. This machine is called the java virtual machine and it exists only inside the computer memory. The process of compiling a java program into byte code which is also referred to as virtual machine code. The virtual machine code is not machine specific. The machine specific code known as machine code is called generated by the java interpreter.
  • 26. 1.3.5 Command line arguments: Sometimes, we may like our programs to act in a particular way depending on the i/p given at the time of execution. This is achieved using command line arguments. Command line arguments are parameters that are supplied to the program at the time of invoking it for execution. Eg;- class Comlinetest { public static void main (String args []) { int count, i=0; String s; count =args.length; System.out.println (“No. of arguments =”+count); while (i<count) { s=args [i]; i=i+1; System.out.println (i+”:”+”java is”+s); }}} Compile using javac comlinetest.java Run using java comlinetest simple object_oriented distributed robust secure o/p No. of arguments =5 1. java is simple 2. java is object oriented 3. java is distributed 4. java is robust java is secure
  • 27. The command line arguments are passed to the program through the array args. The command line has 5 arguments. They are assigned to the array args as follows args[0] =”simple” args[1] = “object. oriented” args[2] = “distributed” args[3] = “robust” args[4] = “secure” o/p No. of arguments =5 1. java is simple 2. java is object oriented 3. java is distributed 4. java is robust 5. java is secure1.3.6 Comments in Java Program: The comment lines give the name of the program, author and other details like why and what of classes and how of algorithms. Comments help to maintain the program. 1. Single line comment The comment is written beginning with Eg: - sample program 2. Multiline comment This comment is written beginning with /* and ending with */ Eg: - /* sample program Written on 25-5-04*/ 3. Documentation comment It is used for generating documentation automatically beginning with /** and ending with * /