SlideShare a Scribd company logo
PROGRAMMING IN JAVA
Dr.K.Kalaiselvi
Dept of Computer Science
Kristu Jayanti college
Bangalore
Course Objective
To inculcate knowledge about the fundamentals of OOPs(Object
oriented programming)
To provide knowledge about developing java applications and
applets
Creating GUI based Java apps and applets that run in a consistent
manner across all platforms. (swings).
1. Balagurusamy.E. Programming with JAVA a Primer.
NewDelhi : Tata McGraw- Hill Publishing Company
Limited.
2.Herbert Schildt. The Complete Reference- Java (7th ed.).
New Delhi : Tata McGraw-Hill Publishing Company
Limited.
Refer : http://javabeginnerstutorial.com/core-java/
Books & References
Introduction to java
Unit-1
4
• Object oriented programming concepts
• Structure of Java programs
• Compiling and running the program
• Printing messages to the screen
Learning outcome of this unit
6
UNIT1:IntroductiontoJavaandFeaturesofJava10hrs
History; Evolution of Java; How Java changed internet; Fundamentals of object-Oriented
programming; Basic concepts of object-oriented programming; Benefits of object-oriented
programming; Features of Java; How Java differs from C And C++; Overview of Java; Simple
Java program; Structure; Java development kit (JDK); Java interpreter; Java virtual machine.
Data types; Variable; Type conversion and casting; Operators and expressions; Programming
structure; Operators and expressions; Decision-making and branching: If; If.. Else; Nested If;
Switch; ?: Operator; Looping: While; Do; For – Jumps In Loops - Labeled loops; Array – Types
ofarrays;Stringhandling.
Some Basics
Q. What is a program?
Ans. A sequence of instructions that a computer can interpret
and execute.
Q. Why Java and not Hindi / Marathi / English?
Ans. Since, so far, computer is not intelligent enough to
understand natural languages.
Contents
 History
 First Java Application
 Data types
 Variables
 Strings
 Assignments
 Math, Boolean expressions
 Relational operations
 If statements
 System.exit
8
What is java?
 A general-purpose object-oriented language.
 Write Once Run Anywhere (WORA).
 Designed for easy Web/Internet applications.
 Widespread acceptance.
Very Brief History
 Started in 1991 by SUN Microsystems
 Targeted at consumer electronics. Wanted reliable programming language.
 Integrated into browsers
 Evolved into write once run anywhere, integrates into Netscape
 General purpose libraries released
10
11 A programming language specifies the words and
symbols that we can use to write a program
A programming language employs a set of rules that
dictate how the words and symbols can be put together to
form valid program statements
The Java programming language was created by Sun
Microsystems, Inc.
It was introduced in 1995 and it's popularity has grown
quickly since
History
James Gosling - Sun Microsystems
Co founder – Vinod Khosla
Oak - Java, May 20, 1995, Sun World
JDK Evolutions
 JDK 1.0 (January 23, 1996)
 JDK 1.1 (February 19, 1997)
 J2SE 1.2 (December 8, 1998)
 J2SE 1.3 (May 8, 2000)
 J2SE 1.4 (February 6, 2002)
 J2SE 5.0 (September 30, 2004)
 Java SE 6 (December 11, 2006)
 Java SE 7 (July 28, 2011)
Cont..
Java Editions.
 J2SE(Java 2 Standard Edition) - to develop client-side standalone applications or
applets.
 J2ME(Java 2 Micro Edition ) - to develop applications for mobile devices such as cell
phones.
 J2EE(Java 2 Enterprise Edition ) - to develop server-side applications such as Java
servlets and Java ServerPages.
Development Environments
 There are many programs that support the development of Java software, including:
 Sun Java Development Kit (JDK)
 Sun NetBeans
 IBM Eclipse
 Borland JBuilder
 MetroWerks CodeWarrior
 BlueJ
 Jgrasp
 Though the details of these environments differ, the basic compilation and execution
process is essentially the same
1-14
Java Attributes/Features
 Familiar, Simple, Small
 Compiled and Interpreted
 Platform-Independent and Portable
 Object-Oriented
 Robust and Secure
 Distributed
 Multithreaded and Interactive
 High Performance
 Dynamic and Extensible
16
Object-Oriented Software Development
problem solving
program design, implementation, and testing
object-oriented concepts
classes
objects
Data Abstraction & encapsulation
Dynamic Binding
inheritance
Polymorphism
Message communication
graphical user interfaces
17
BENEFITS OF OOPS
1. Data hiding helps the programmer to build secure programs.
2. Possible to have multiple objects to coexist without any interference.
3. Easy to partition the work in a project based on objects .
4. Message passing between objects makes the interface description with external
systems much simple.
5. Software complexity can be easily managed.
APPLICATIONS OF OOP``
1. Real time systems
2. Simulation and modeling
3. Object oriented DB
4. Hypertext, hypermedia
5. AI & expert systems
6. Neural networks and parallel programming
7. Office automation system
18
In the Java programming language:
A program is made up of one or more
classes
A class contains one or more methods
A method contains program statements
These terms will be explored in detail
throughout the course
A Java application always contains a method
called main
Programming Languages
 Each type of CPU executes only a particular machine language
 A program must be translated into machine language before it can be executed
 A compiler is a software tool which translates source code into a specific target
language
 Often, that target language is the machine language for a particular CPU type
 The Java approach is somewhat different
1-19
Java Translation
 The Java compiler translates Java source code into a special representation called
bytecode
 Java bytecode is not the machine language for any traditional CPU
 Another software tool, called an interpreter, translates bytecode into machine
language and executes it.
 Therefore the Java compiler is not tied to any particular machine
 Java is considered to be architecture-neutral
1-20
Java Translation (JVM)
Java source
code
Machine
code
Java
bytecode
Bytecode
interpreter
Bytecode
compiler
Java
compiler
• JAVA VIRTUAL MACHINE
• JUST IN TIME (JIT) EXECUTION.
• PLATFORM INDEPENDENT.
• INTERNET LANGUAGE ??
Java is Compiled and Interpreted
Text Editor Compiler Interpreter
Programmer
Source Code
.java file
Byte Code
.class file
Hardware and
Operating System
Notepad,
emacs,vi
javac java
appletviewer
netscape
Compiled Languages
Text Editor Compiler linker
Programmer
Source Code
.c file
Object Code
.o file
Notepad,
emacs,vi
gcc
Executable
Code
a.out file
Total Platform Independence
JAVA COMPILER
JAVA BYTE CODE
JAVA INTERPRETER
Windows 95 Macintosh Solaris Windows NT
(translator)
(same for all platforms)
(one for each different system)
Architecture Neutral & Portable
 Java Compiler - Java source code (file with extension .java) to
bytecode (file with extension .class)
 Bytecode - an intermediate form, closer to machine representation
 A interpreter (virtual machine) on any target platform interprets the
bytecode.
Architecture Neutral & Portable
 Porting the java system to any new platform involves writing an interpreter.
 The interpreter will figure out what the equivalent machine dependent code to run
Java better than C++ ?
 No Typedefs, Defines, or Preprocessor
 No Global Variables
 No Goto statements
 No Pointers
 No Unsafe Structures
 No Multiple Inheritance
 No Operator Overloading
 No Automatic Coercions
 No Fragile Data Types
Java Applications
 We can develop two types of Java programs:
 Stand-alone applications
 Web applications (applets)
Applications v/s Applets
 Different ways to run a Java executable are:
Application- A stand-alone program that can be invoked from command line . A
program that has a “main” method
Applet- A program embedded in a web page , to be run when the page is browsed . A
program that contains no “main” method
Applets v/s Applications
 Different ways to run a Java executable are
Application- A stand-alone program that can be invoked from command line . A
program that has a “main” method
Applet- A program embedded in a web page , to be run when the page is browsed . A
program that contains no “main” method
 Application –Executed by the Java interpreter.
 Applet- Java enabled web browser.
Syntax and Semantics
 The syntax rules of a language define how we can put together symbols, reserved
words, and identifiers to make a valid program
 The semantics of a program statement define what that statement means (its
purpose or role in a program)
 A program that is syntactically correct is not necessarily logically (semantically)
correct
 A program will always do what we tell it to do, not what we meant to tell it to do
1-31
Errors
 A program can have three types of errors
 The compiler will find syntax errors and other basic problems (compile-time errors)
 If compile-time errors exist, an executable version of the program is not created
 A problem can occur during program execution, such as trying to divide by zero,
which causes a program to terminate abnormally (run-time errors)
 A program may run, but produce incorrect results, perhaps using an incorrect formula
(logical errors)
1-32
Basic Program Development
1-33
errors
errors
Edit and
save program
Compile program
Execute program and
evaluate results
How is Java different from C…
 C Language:
 Major difference is that C is a structure oriented language and Java is
an object oriented language and has mechanism to define classes and
objects.
 Java does not support an explicit pointer type
 Java does not have preprocessor, so we cant use #define, #include and
#ifdef statements.
 Java does not include structures, unions and enum data types.
 Java does not include keywords like goto, sizeof and typedef.
 Java adds labeled break and continue statements.
 Java adds many features required for object oriented programming.
How is Java different from C++…
 C++ language
Features removed in java:
 Java doesn’t support pointers to avoid unauthorized access of memory locations.
 Java does not include structures, unions and enum data types.
 Java does not support operator over loading.
 Preprocessor plays less important role in C++ and so eliminated entirely in java.
 Java does not perform automatic type conversions that result in loss of precision.
Cont…
 Java does not support global variables. Every method and variable is
declared within a class and forms part of that class.
 Java does not allow default arguments.
 Java does not support inheritance of multiple super classes by a sub class
(i.e., multiple inheritance). This is accomplished by using ‘interface’ concept.
 It is not possible to declare unsigned integers in java.
 In java objects are passed by reference only. In C++ objects may be passed
by value or reference.
Cont …
New features added in Java:
 Multithreading, that allows two or more pieces of the same program to execute
concurrently.
 C++ has a set of library functions that use a common header file. But java replaces it
with its own set of API classes.
 It adds packages and interfaces.
 Java supports automatic garbage collection.
 break and continue statements have been enhanced in java to accept labels as targets.
 The use of unicode characters ensures portability.
Cont …
Features that differ:
 Though C++ and java supports Boolean data type, C++ takes any
nonzero value as true and zero as false. True and false in java are
predefined literals that are values for a boolean expression.
 Java has replaced the destructor function with a finalize() function.
 C++ supports exception handling that is similar to java's. However,
in C++ there is no requirement that a thrown exception be caught.
Characteristics of Java
 Java is simple-C & C++ features are
adapted.
 Java is object-oriented-classes as
packages and objects.
 Java is distributed-it can share both
data and programs.
 Java is compiled & interpreted
 Java is robust
 Java is architecture-neutral
 Java is portable
 Java’s high performance-
Multithreading
 Java is multithreaded-multiple
 Java is dynamic-supports functions of
c & c++
Java is secure
Java Environment
 Java includes many development tools, classes and methods
 Development tools are part of Java Development Kit (JDK) and
 The classes and methods are part of Java Standard Library (JSL), also
known as Application Programming Interface (API).
 JDK constitutes of tools like java compiler, java interpreter and
many.
 API includes hundreds of classes and methods grouped into
several packages according to their functionality.
First Application
/**
*Hello World, first application, only output.
*/
public class hello{
public static void main (String [] args) {
System.out.println(“Hello Worldn”);
} //end main
}//end class
41
public is the visibility. This can be public, private, protected or (if you omit a value)
default.
static is a special [optional] keyword that indicates that this method can be called
without creating an instance of this class. Without it, you have to instantiate this class
and call this method from the resulting object.
void is the return type of this method, indicating that this method doesn't return
anything. Methods must have a return type.
42
 main( ... ) is the name of this method. Methods have to be named. The
parentheses indicate that this is a method.
 String[] args is a single parameter for the method. String[] is the type of the
parameter, indicating an array of Strings. args is the name of the parameter.
Parameters must be named.
43
How to get it running
 Text in hello.java file
 Why?
 To compile:
 javac hello.java
 To run:
 java hello
44
 Case Sensitivity - Java is case sensitive, which means identifier Hello and hello
would have different meaning in Java.
 Class Names - For all class names the first letter should be in Upper Case.
 If several words are used to form a name of the class, each inner word's first letter
should be in Upper Case.
Example class MyFirstJavaClass
 Method Names - All method names should start with a Lower
Case letter.
If several words are used to form the name of the method,
each inner word's first letter should be in Upper Case.
Example public void myMethodName()
Notice:
 Java is CASE SENSITIVE!!
 Whitespace is ignored by compiler
 Whitespace makes things easier to read…hence it affects your grade 
 File name has to be the same as class name in file.
 Need to import necessary class definitions
46
 Program File Name - Name of the program file should exactly match the class
name.
When saving the file, you should save it using the class name (Remember Java is
case sensitive) and append '.java' to the end of the name (if the file name and
class name do not match your program will not compile).
Example : Assume 'MyFirstJavaProgram' is the class name. Then the file should
saved as 'MyFirstJavaProgram.java'
Java program structure
 Thank you..Lets meet in the implementation of OOPs concept in JAVA

More Related Content

What's hot

Operators in java
Operators in javaOperators in java
Operators in java
AbhishekMondal42
 
Java awt (abstract window toolkit)
Java awt (abstract window toolkit)Java awt (abstract window toolkit)
Java awt (abstract window toolkit)
Elizabeth alexander
 
Java Data Types
Java Data TypesJava Data Types
Java Data Types
Spotle.ai
 
Android activity lifecycle
Android activity lifecycleAndroid activity lifecycle
Android activity lifecycle
Soham Patel
 
Event Handling in java
Event Handling in javaEvent Handling in java
Event Handling in java
Google
 
Core java complete ppt(note)
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)
arvind pandey
 
Classes objects in java
Classes objects in javaClasses objects in java
Classes objects in java
Madishetty Prathibha
 
Ppt on this and super keyword
Ppt on this and super keywordPpt on this and super keyword
Ppt on this and super keyword
tanu_jaswal
 
Java: The Complete Reference, Eleventh Edition
Java: The Complete Reference, Eleventh EditionJava: The Complete Reference, Eleventh Edition
Java: The Complete Reference, Eleventh Edition
moxuji
 
Java tokens
Java tokensJava tokens
Java tokens
shalinikarunakaran1
 
9. Input Output in java
9. Input Output in java9. Input Output in java
9. Input Output in java
Nilesh Dalvi
 
Java multi threading
Java multi threadingJava multi threading
Java multi threading
Raja Sekhar
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
SIVASHANKARIRAJAN
 
JDK,JRE,JVM
JDK,JRE,JVMJDK,JRE,JVM
JDK,JRE,JVM
Cognizant
 
Java IO
Java IOJava IO
Java IO
UTSAB NEUPANE
 
Event handling
Event handlingEvent handling
Event handling
swapnac12
 
Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...
Mr. Akaash
 
Constants, Variables and Data Types in Java
Constants, Variables and Data Types in JavaConstants, Variables and Data Types in Java
Constants, Variables and Data Types in JavaAbhilash Nair
 
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
 

What's hot (20)

OOP java
OOP javaOOP java
OOP java
 
Operators in java
Operators in javaOperators in java
Operators in java
 
Java awt (abstract window toolkit)
Java awt (abstract window toolkit)Java awt (abstract window toolkit)
Java awt (abstract window toolkit)
 
Java Data Types
Java Data TypesJava Data Types
Java Data Types
 
Android activity lifecycle
Android activity lifecycleAndroid activity lifecycle
Android activity lifecycle
 
Event Handling in java
Event Handling in javaEvent Handling in java
Event Handling in java
 
Core java complete ppt(note)
Core java  complete  ppt(note)Core java  complete  ppt(note)
Core java complete ppt(note)
 
Classes objects in java
Classes objects in javaClasses objects in java
Classes objects in java
 
Ppt on this and super keyword
Ppt on this and super keywordPpt on this and super keyword
Ppt on this and super keyword
 
Java: The Complete Reference, Eleventh Edition
Java: The Complete Reference, Eleventh EditionJava: The Complete Reference, Eleventh Edition
Java: The Complete Reference, Eleventh Edition
 
Java tokens
Java tokensJava tokens
Java tokens
 
9. Input Output in java
9. Input Output in java9. Input Output in java
9. Input Output in java
 
Java multi threading
Java multi threadingJava multi threading
Java multi threading
 
Constructor in java
Constructor in javaConstructor in java
Constructor in java
 
JDK,JRE,JVM
JDK,JRE,JVMJDK,JRE,JVM
JDK,JRE,JVM
 
Java IO
Java IOJava IO
Java IO
 
Event handling
Event handlingEvent handling
Event handling
 
Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...Introduction to Java Programming, Basic Structure, variables Data type, input...
Introduction to Java Programming, Basic Structure, variables Data type, input...
 
Constants, Variables and Data Types in Java
Constants, Variables and Data Types in JavaConstants, Variables and Data Types in Java
Constants, Variables and Data Types in Java
 
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
 

Similar to Introduction to java

ICT-DBA4 -05-0811-Apply-Object-Oriented-Programming-Language-Skills.doc
ICT-DBA4 -05-0811-Apply-Object-Oriented-Programming-Language-Skills.docICT-DBA4 -05-0811-Apply-Object-Oriented-Programming-Language-Skills.doc
ICT-DBA4 -05-0811-Apply-Object-Oriented-Programming-Language-Skills.doc
AmanGunner
 
Java Programming Basics
Java Programming BasicsJava Programming Basics
Java Programming Basics
Rkrishna Mishra
 
C,c++,java,php,.net training institute in delhi, best training institute for ...
C,c++,java,php,.net training institute in delhi, best training institute for ...C,c++,java,php,.net training institute in delhi, best training institute for ...
C,c++,java,php,.net training institute in delhi, best training institute for ...MCM COmpetitive Classes
 
Java1
Java1Java1
Java
Java Java
Unit1 introduction to Java
Unit1 introduction to JavaUnit1 introduction to Java
Unit1 introduction to Java
DevaKumari Vijay
 
Java Lecture 1
Java Lecture 1Java Lecture 1
Java Lecture 1
Qualys
 
JAVA PROGRAMMING-Unit I - Final PPT.pptx
JAVA PROGRAMMING-Unit I - Final PPT.pptxJAVA PROGRAMMING-Unit I - Final PPT.pptx
JAVA PROGRAMMING-Unit I - Final PPT.pptx
SuganthiDPSGRKCW
 
Java Intro
Java IntroJava Intro
Java Intro
Nazmul Hasan Rupok
 
Project report for final year project
Project report for final year projectProject report for final year project
Project report for final year project
suneel singh
 
0f0cef_1dac552af56c4338ab0672859199e693.pdf
0f0cef_1dac552af56c4338ab0672859199e693.pdf0f0cef_1dac552af56c4338ab0672859199e693.pdf
0f0cef_1dac552af56c4338ab0672859199e693.pdf
DeepakChaudhriAmbali
 
Java ms harsha
Java ms harshaJava ms harsha
Java ms harsha
Harsha Batra
 
Elements of Java Language
Elements of Java Language Elements of Java Language
Elements of Java Language
Hitesh-Java
 
1.INTRODUCTION TO JAVA_2022 MB.ppt .
1.INTRODUCTION TO JAVA_2022 MB.ppt      .1.INTRODUCTION TO JAVA_2022 MB.ppt      .
1.INTRODUCTION TO JAVA_2022 MB.ppt .
happycocoman
 
Core Java Slides
Core Java SlidesCore Java Slides
Core Java Slides
Vinit Vyas
 
Java Is A Programming Dialect And Registering Stage Essay
Java Is A Programming Dialect And Registering Stage EssayJava Is A Programming Dialect And Registering Stage Essay
Java Is A Programming Dialect And Registering Stage Essay
Liz Sims
 
Java presentation
Java presentationJava presentation
Java presentation
Karan Sareen
 
Java programming language basics
Java programming language basicsJava programming language basics
Java programming language basics
dharmendra kumar dhakar
 
Vb.net basics 1(vb,net--3 year)
Vb.net basics 1(vb,net--3 year)Vb.net basics 1(vb,net--3 year)
Vb.net basics 1(vb,net--3 year)
Ankit Gupta
 

Similar to Introduction to java (20)

ICT-DBA4 -05-0811-Apply-Object-Oriented-Programming-Language-Skills.doc
ICT-DBA4 -05-0811-Apply-Object-Oriented-Programming-Language-Skills.docICT-DBA4 -05-0811-Apply-Object-Oriented-Programming-Language-Skills.doc
ICT-DBA4 -05-0811-Apply-Object-Oriented-Programming-Language-Skills.doc
 
Java Programming Basics
Java Programming BasicsJava Programming Basics
Java Programming Basics
 
C,c++,java,php,.net training institute in delhi, best training institute for ...
C,c++,java,php,.net training institute in delhi, best training institute for ...C,c++,java,php,.net training institute in delhi, best training institute for ...
C,c++,java,php,.net training institute in delhi, best training institute for ...
 
Java1
Java1Java1
Java1
 
Java
Java Java
Java
 
Unit1 introduction to Java
Unit1 introduction to JavaUnit1 introduction to Java
Unit1 introduction to Java
 
Java Lecture 1
Java Lecture 1Java Lecture 1
Java Lecture 1
 
JAVA PROGRAMMING-Unit I - Final PPT.pptx
JAVA PROGRAMMING-Unit I - Final PPT.pptxJAVA PROGRAMMING-Unit I - Final PPT.pptx
JAVA PROGRAMMING-Unit I - Final PPT.pptx
 
Java Intro
Java IntroJava Intro
Java Intro
 
report
reportreport
report
 
Project report for final year project
Project report for final year projectProject report for final year project
Project report for final year project
 
0f0cef_1dac552af56c4338ab0672859199e693.pdf
0f0cef_1dac552af56c4338ab0672859199e693.pdf0f0cef_1dac552af56c4338ab0672859199e693.pdf
0f0cef_1dac552af56c4338ab0672859199e693.pdf
 
Java ms harsha
Java ms harshaJava ms harsha
Java ms harsha
 
Elements of Java Language
Elements of Java Language Elements of Java Language
Elements of Java Language
 
1.INTRODUCTION TO JAVA_2022 MB.ppt .
1.INTRODUCTION TO JAVA_2022 MB.ppt      .1.INTRODUCTION TO JAVA_2022 MB.ppt      .
1.INTRODUCTION TO JAVA_2022 MB.ppt .
 
Core Java Slides
Core Java SlidesCore Java Slides
Core Java Slides
 
Java Is A Programming Dialect And Registering Stage Essay
Java Is A Programming Dialect And Registering Stage EssayJava Is A Programming Dialect And Registering Stage Essay
Java Is A Programming Dialect And Registering Stage Essay
 
Java presentation
Java presentationJava presentation
Java presentation
 
Java programming language basics
Java programming language basicsJava programming language basics
Java programming language basics
 
Vb.net basics 1(vb,net--3 year)
Vb.net basics 1(vb,net--3 year)Vb.net basics 1(vb,net--3 year)
Vb.net basics 1(vb,net--3 year)
 

More from Kalai Selvi

cloud services and providers
cloud services and providerscloud services and providers
cloud services and providers
Kalai Selvi
 
cloud concepts and technologies
cloud concepts and technologiescloud concepts and technologies
cloud concepts and technologies
Kalai Selvi
 
cloud computing
cloud computingcloud computing
cloud computing
Kalai Selvi
 
I Semester-Unit 3 Boolean Algebra.pptx
I Semester-Unit 3 Boolean Algebra.pptxI Semester-Unit 3 Boolean Algebra.pptx
I Semester-Unit 3 Boolean Algebra.pptx
Kalai Selvi
 
I semester-SOP-POS expressions.pptx
I semester-SOP-POS expressions.pptxI semester-SOP-POS expressions.pptx
I semester-SOP-POS expressions.pptx
Kalai Selvi
 
I Semester-Unit 3 Boolean Algebra.pptx
I Semester-Unit 3 Boolean Algebra.pptxI Semester-Unit 3 Boolean Algebra.pptx
I Semester-Unit 3 Boolean Algebra.pptx
Kalai Selvi
 
Multimedia Authoring Tools.ppt
Multimedia Authoring Tools.pptMultimedia Authoring Tools.ppt
Multimedia Authoring Tools.ppt
Kalai Selvi
 
Process of Making Multimedia.ppt
Process of Making Multimedia.pptProcess of Making Multimedia.ppt
Process of Making Multimedia.ppt
Kalai Selvi
 
Unit3 inheritance
Unit3 inheritanceUnit3 inheritance
Unit3 inheritance
Kalai Selvi
 
Unit3 packages & interfaces
Unit3 packages & interfacesUnit3 packages & interfaces
Unit3 packages & interfaces
Kalai Selvi
 
Introduction to Artificial Intelligence
Introduction to Artificial IntelligenceIntroduction to Artificial Intelligence
Introduction to Artificial Intelligence
Kalai Selvi
 
Searching techniques in AI
Searching techniques in AISearching techniques in AI
Searching techniques in AI
Kalai Selvi
 
Introduction to Artificial Intelligence
Introduction to Artificial IntelligenceIntroduction to Artificial Intelligence
Introduction to Artificial Intelligence
Kalai Selvi
 
AWT controls, Listeners
AWT controls, ListenersAWT controls, Listeners
AWT controls, Listeners
Kalai Selvi
 
AWT controls, Listeners
AWT controls, ListenersAWT controls, Listeners
AWT controls, Listeners
Kalai Selvi
 
Unit 1 part 2
Unit 1  part 2Unit 1  part 2
Unit 1 part 2
Kalai Selvi
 
Unit 1 part 1
Unit 1   part 1Unit 1   part 1
Unit 1 part 1
Kalai Selvi
 
Unit 4 combinational circuit
Unit 4 combinational circuitUnit 4 combinational circuit
Unit 4 combinational circuit
Kalai Selvi
 
Unit 3 file management
Unit 3 file managementUnit 3 file management
Unit 3 file management
Kalai Selvi
 
Unit 3 chapter 1-file management
Unit 3 chapter 1-file managementUnit 3 chapter 1-file management
Unit 3 chapter 1-file management
Kalai Selvi
 

More from Kalai Selvi (20)

cloud services and providers
cloud services and providerscloud services and providers
cloud services and providers
 
cloud concepts and technologies
cloud concepts and technologiescloud concepts and technologies
cloud concepts and technologies
 
cloud computing
cloud computingcloud computing
cloud computing
 
I Semester-Unit 3 Boolean Algebra.pptx
I Semester-Unit 3 Boolean Algebra.pptxI Semester-Unit 3 Boolean Algebra.pptx
I Semester-Unit 3 Boolean Algebra.pptx
 
I semester-SOP-POS expressions.pptx
I semester-SOP-POS expressions.pptxI semester-SOP-POS expressions.pptx
I semester-SOP-POS expressions.pptx
 
I Semester-Unit 3 Boolean Algebra.pptx
I Semester-Unit 3 Boolean Algebra.pptxI Semester-Unit 3 Boolean Algebra.pptx
I Semester-Unit 3 Boolean Algebra.pptx
 
Multimedia Authoring Tools.ppt
Multimedia Authoring Tools.pptMultimedia Authoring Tools.ppt
Multimedia Authoring Tools.ppt
 
Process of Making Multimedia.ppt
Process of Making Multimedia.pptProcess of Making Multimedia.ppt
Process of Making Multimedia.ppt
 
Unit3 inheritance
Unit3 inheritanceUnit3 inheritance
Unit3 inheritance
 
Unit3 packages & interfaces
Unit3 packages & interfacesUnit3 packages & interfaces
Unit3 packages & interfaces
 
Introduction to Artificial Intelligence
Introduction to Artificial IntelligenceIntroduction to Artificial Intelligence
Introduction to Artificial Intelligence
 
Searching techniques in AI
Searching techniques in AISearching techniques in AI
Searching techniques in AI
 
Introduction to Artificial Intelligence
Introduction to Artificial IntelligenceIntroduction to Artificial Intelligence
Introduction to Artificial Intelligence
 
AWT controls, Listeners
AWT controls, ListenersAWT controls, Listeners
AWT controls, Listeners
 
AWT controls, Listeners
AWT controls, ListenersAWT controls, Listeners
AWT controls, Listeners
 
Unit 1 part 2
Unit 1  part 2Unit 1  part 2
Unit 1 part 2
 
Unit 1 part 1
Unit 1   part 1Unit 1   part 1
Unit 1 part 1
 
Unit 4 combinational circuit
Unit 4 combinational circuitUnit 4 combinational circuit
Unit 4 combinational circuit
 
Unit 3 file management
Unit 3 file managementUnit 3 file management
Unit 3 file management
 
Unit 3 chapter 1-file management
Unit 3 chapter 1-file managementUnit 3 chapter 1-file management
Unit 3 chapter 1-file management
 

Recently uploaded

Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
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
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
PedroFerreira53928
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
joachimlavalley1
 
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
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
bennyroshan06
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
EduSkills OECD
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
Steve Thomason
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
MysoreMuleSoftMeetup
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Thiyagu K
 
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
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
Delapenabediema
 
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
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
AzmatAli747758
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
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
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 

Recently uploaded (20)

Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
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
 
PART A. Introduction to Costumer Service
PART A. Introduction to Costumer ServicePART A. Introduction to Costumer Service
PART A. Introduction to Costumer Service
 
Additional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdfAdditional Benefits for Employee Website.pdf
Additional Benefits for Employee Website.pdf
 
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
 
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptxMARUTI SUZUKI- A Successful Joint Venture in India.pptx
MARUTI SUZUKI- A Successful Joint Venture in India.pptx
 
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptxStudents, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
Students, digital devices and success - Andreas Schleicher - 27 May 2024..pptx
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 
The Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve ThomasonThe Art Pastor's Guide to Sabbath | Steve Thomason
The Art Pastor's Guide to Sabbath | Steve Thomason
 
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
Mule 4.6 & Java 17 Upgrade | MuleSoft Mysore Meetup #46
 
Unit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdfUnit 2- Research Aptitude (UGC NET Paper I).pdf
Unit 2- Research Aptitude (UGC NET Paper I).pdf
 
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
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
The Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official PublicationThe Challenger.pdf DNHS Official Publication
The Challenger.pdf DNHS Official Publication
 
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
 
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...Cambridge International AS  A Level Biology Coursebook - EBook (MaryFosbery J...
Cambridge International AS A Level Biology Coursebook - EBook (MaryFosbery J...
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
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
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
 

Introduction to java

  • 1. PROGRAMMING IN JAVA Dr.K.Kalaiselvi Dept of Computer Science Kristu Jayanti college Bangalore
  • 2. Course Objective To inculcate knowledge about the fundamentals of OOPs(Object oriented programming) To provide knowledge about developing java applications and applets Creating GUI based Java apps and applets that run in a consistent manner across all platforms. (swings).
  • 3. 1. Balagurusamy.E. Programming with JAVA a Primer. NewDelhi : Tata McGraw- Hill Publishing Company Limited. 2.Herbert Schildt. The Complete Reference- Java (7th ed.). New Delhi : Tata McGraw-Hill Publishing Company Limited. Refer : http://javabeginnerstutorial.com/core-java/ Books & References
  • 5. • Object oriented programming concepts • Structure of Java programs • Compiling and running the program • Printing messages to the screen Learning outcome of this unit
  • 6. 6 UNIT1:IntroductiontoJavaandFeaturesofJava10hrs History; Evolution of Java; How Java changed internet; Fundamentals of object-Oriented programming; Basic concepts of object-oriented programming; Benefits of object-oriented programming; Features of Java; How Java differs from C And C++; Overview of Java; Simple Java program; Structure; Java development kit (JDK); Java interpreter; Java virtual machine. Data types; Variable; Type conversion and casting; Operators and expressions; Programming structure; Operators and expressions; Decision-making and branching: If; If.. Else; Nested If; Switch; ?: Operator; Looping: While; Do; For – Jumps In Loops - Labeled loops; Array – Types ofarrays;Stringhandling.
  • 7. Some Basics Q. What is a program? Ans. A sequence of instructions that a computer can interpret and execute. Q. Why Java and not Hindi / Marathi / English? Ans. Since, so far, computer is not intelligent enough to understand natural languages.
  • 8. Contents  History  First Java Application  Data types  Variables  Strings  Assignments  Math, Boolean expressions  Relational operations  If statements  System.exit 8
  • 9. What is java?  A general-purpose object-oriented language.  Write Once Run Anywhere (WORA).  Designed for easy Web/Internet applications.  Widespread acceptance.
  • 10. Very Brief History  Started in 1991 by SUN Microsystems  Targeted at consumer electronics. Wanted reliable programming language.  Integrated into browsers  Evolved into write once run anywhere, integrates into Netscape  General purpose libraries released 10
  • 11. 11 A programming language specifies the words and symbols that we can use to write a program A programming language employs a set of rules that dictate how the words and symbols can be put together to form valid program statements The Java programming language was created by Sun Microsystems, Inc. It was introduced in 1995 and it's popularity has grown quickly since
  • 12. History James Gosling - Sun Microsystems Co founder – Vinod Khosla Oak - Java, May 20, 1995, Sun World JDK Evolutions  JDK 1.0 (January 23, 1996)  JDK 1.1 (February 19, 1997)  J2SE 1.2 (December 8, 1998)  J2SE 1.3 (May 8, 2000)  J2SE 1.4 (February 6, 2002)  J2SE 5.0 (September 30, 2004)  Java SE 6 (December 11, 2006)  Java SE 7 (July 28, 2011)
  • 13. Cont.. Java Editions.  J2SE(Java 2 Standard Edition) - to develop client-side standalone applications or applets.  J2ME(Java 2 Micro Edition ) - to develop applications for mobile devices such as cell phones.  J2EE(Java 2 Enterprise Edition ) - to develop server-side applications such as Java servlets and Java ServerPages.
  • 14. Development Environments  There are many programs that support the development of Java software, including:  Sun Java Development Kit (JDK)  Sun NetBeans  IBM Eclipse  Borland JBuilder  MetroWerks CodeWarrior  BlueJ  Jgrasp  Though the details of these environments differ, the basic compilation and execution process is essentially the same 1-14
  • 15. Java Attributes/Features  Familiar, Simple, Small  Compiled and Interpreted  Platform-Independent and Portable  Object-Oriented  Robust and Secure  Distributed  Multithreaded and Interactive  High Performance  Dynamic and Extensible
  • 16. 16 Object-Oriented Software Development problem solving program design, implementation, and testing object-oriented concepts classes objects Data Abstraction & encapsulation Dynamic Binding inheritance Polymorphism Message communication graphical user interfaces
  • 17. 17 BENEFITS OF OOPS 1. Data hiding helps the programmer to build secure programs. 2. Possible to have multiple objects to coexist without any interference. 3. Easy to partition the work in a project based on objects . 4. Message passing between objects makes the interface description with external systems much simple. 5. Software complexity can be easily managed. APPLICATIONS OF OOP`` 1. Real time systems 2. Simulation and modeling 3. Object oriented DB 4. Hypertext, hypermedia 5. AI & expert systems 6. Neural networks and parallel programming 7. Office automation system
  • 18. 18 In the Java programming language: A program is made up of one or more classes A class contains one or more methods A method contains program statements These terms will be explored in detail throughout the course A Java application always contains a method called main
  • 19. Programming Languages  Each type of CPU executes only a particular machine language  A program must be translated into machine language before it can be executed  A compiler is a software tool which translates source code into a specific target language  Often, that target language is the machine language for a particular CPU type  The Java approach is somewhat different 1-19
  • 20. Java Translation  The Java compiler translates Java source code into a special representation called bytecode  Java bytecode is not the machine language for any traditional CPU  Another software tool, called an interpreter, translates bytecode into machine language and executes it.  Therefore the Java compiler is not tied to any particular machine  Java is considered to be architecture-neutral 1-20
  • 21. Java Translation (JVM) Java source code Machine code Java bytecode Bytecode interpreter Bytecode compiler Java compiler • JAVA VIRTUAL MACHINE • JUST IN TIME (JIT) EXECUTION. • PLATFORM INDEPENDENT. • INTERNET LANGUAGE ??
  • 22. Java is Compiled and Interpreted Text Editor Compiler Interpreter Programmer Source Code .java file Byte Code .class file Hardware and Operating System Notepad, emacs,vi javac java appletviewer netscape
  • 23. Compiled Languages Text Editor Compiler linker Programmer Source Code .c file Object Code .o file Notepad, emacs,vi gcc Executable Code a.out file
  • 24. Total Platform Independence JAVA COMPILER JAVA BYTE CODE JAVA INTERPRETER Windows 95 Macintosh Solaris Windows NT (translator) (same for all platforms) (one for each different system)
  • 25. Architecture Neutral & Portable  Java Compiler - Java source code (file with extension .java) to bytecode (file with extension .class)  Bytecode - an intermediate form, closer to machine representation  A interpreter (virtual machine) on any target platform interprets the bytecode.
  • 26. Architecture Neutral & Portable  Porting the java system to any new platform involves writing an interpreter.  The interpreter will figure out what the equivalent machine dependent code to run
  • 27. Java better than C++ ?  No Typedefs, Defines, or Preprocessor  No Global Variables  No Goto statements  No Pointers  No Unsafe Structures  No Multiple Inheritance  No Operator Overloading  No Automatic Coercions  No Fragile Data Types
  • 28. Java Applications  We can develop two types of Java programs:  Stand-alone applications  Web applications (applets)
  • 29. Applications v/s Applets  Different ways to run a Java executable are: Application- A stand-alone program that can be invoked from command line . A program that has a “main” method Applet- A program embedded in a web page , to be run when the page is browsed . A program that contains no “main” method
  • 30. Applets v/s Applications  Different ways to run a Java executable are Application- A stand-alone program that can be invoked from command line . A program that has a “main” method Applet- A program embedded in a web page , to be run when the page is browsed . A program that contains no “main” method  Application –Executed by the Java interpreter.  Applet- Java enabled web browser.
  • 31. Syntax and Semantics  The syntax rules of a language define how we can put together symbols, reserved words, and identifiers to make a valid program  The semantics of a program statement define what that statement means (its purpose or role in a program)  A program that is syntactically correct is not necessarily logically (semantically) correct  A program will always do what we tell it to do, not what we meant to tell it to do 1-31
  • 32. Errors  A program can have three types of errors  The compiler will find syntax errors and other basic problems (compile-time errors)  If compile-time errors exist, an executable version of the program is not created  A problem can occur during program execution, such as trying to divide by zero, which causes a program to terminate abnormally (run-time errors)  A program may run, but produce incorrect results, perhaps using an incorrect formula (logical errors) 1-32
  • 33. Basic Program Development 1-33 errors errors Edit and save program Compile program Execute program and evaluate results
  • 34. How is Java different from C…  C Language:  Major difference is that C is a structure oriented language and Java is an object oriented language and has mechanism to define classes and objects.  Java does not support an explicit pointer type  Java does not have preprocessor, so we cant use #define, #include and #ifdef statements.  Java does not include structures, unions and enum data types.  Java does not include keywords like goto, sizeof and typedef.  Java adds labeled break and continue statements.  Java adds many features required for object oriented programming.
  • 35. How is Java different from C++…  C++ language Features removed in java:  Java doesn’t support pointers to avoid unauthorized access of memory locations.  Java does not include structures, unions and enum data types.  Java does not support operator over loading.  Preprocessor plays less important role in C++ and so eliminated entirely in java.  Java does not perform automatic type conversions that result in loss of precision.
  • 36. Cont…  Java does not support global variables. Every method and variable is declared within a class and forms part of that class.  Java does not allow default arguments.  Java does not support inheritance of multiple super classes by a sub class (i.e., multiple inheritance). This is accomplished by using ‘interface’ concept.  It is not possible to declare unsigned integers in java.  In java objects are passed by reference only. In C++ objects may be passed by value or reference.
  • 37. Cont … New features added in Java:  Multithreading, that allows two or more pieces of the same program to execute concurrently.  C++ has a set of library functions that use a common header file. But java replaces it with its own set of API classes.  It adds packages and interfaces.  Java supports automatic garbage collection.  break and continue statements have been enhanced in java to accept labels as targets.  The use of unicode characters ensures portability.
  • 38. Cont … Features that differ:  Though C++ and java supports Boolean data type, C++ takes any nonzero value as true and zero as false. True and false in java are predefined literals that are values for a boolean expression.  Java has replaced the destructor function with a finalize() function.  C++ supports exception handling that is similar to java's. However, in C++ there is no requirement that a thrown exception be caught.
  • 39. Characteristics of Java  Java is simple-C & C++ features are adapted.  Java is object-oriented-classes as packages and objects.  Java is distributed-it can share both data and programs.  Java is compiled & interpreted  Java is robust  Java is architecture-neutral  Java is portable  Java’s high performance- Multithreading  Java is multithreaded-multiple  Java is dynamic-supports functions of c & c++ Java is secure
  • 40. Java Environment  Java includes many development tools, classes and methods  Development tools are part of Java Development Kit (JDK) and  The classes and methods are part of Java Standard Library (JSL), also known as Application Programming Interface (API).  JDK constitutes of tools like java compiler, java interpreter and many.  API includes hundreds of classes and methods grouped into several packages according to their functionality.
  • 41. First Application /** *Hello World, first application, only output. */ public class hello{ public static void main (String [] args) { System.out.println(“Hello Worldn”); } //end main }//end class 41
  • 42. public is the visibility. This can be public, private, protected or (if you omit a value) default. static is a special [optional] keyword that indicates that this method can be called without creating an instance of this class. Without it, you have to instantiate this class and call this method from the resulting object. void is the return type of this method, indicating that this method doesn't return anything. Methods must have a return type. 42
  • 43.  main( ... ) is the name of this method. Methods have to be named. The parentheses indicate that this is a method.  String[] args is a single parameter for the method. String[] is the type of the parameter, indicating an array of Strings. args is the name of the parameter. Parameters must be named. 43
  • 44. How to get it running  Text in hello.java file  Why?  To compile:  javac hello.java  To run:  java hello 44
  • 45.  Case Sensitivity - Java is case sensitive, which means identifier Hello and hello would have different meaning in Java.  Class Names - For all class names the first letter should be in Upper Case.  If several words are used to form a name of the class, each inner word's first letter should be in Upper Case. Example class MyFirstJavaClass  Method Names - All method names should start with a Lower Case letter. If several words are used to form the name of the method, each inner word's first letter should be in Upper Case. Example public void myMethodName()
  • 46. Notice:  Java is CASE SENSITIVE!!  Whitespace is ignored by compiler  Whitespace makes things easier to read…hence it affects your grade   File name has to be the same as class name in file.  Need to import necessary class definitions 46
  • 47.  Program File Name - Name of the program file should exactly match the class name. When saving the file, you should save it using the class name (Remember Java is case sensitive) and append '.java' to the end of the name (if the file name and class name do not match your program will not compile). Example : Assume 'MyFirstJavaProgram' is the class name. Then the file should saved as 'MyFirstJavaProgram.java'
  • 49.  Thank you..Lets meet in the implementation of OOPs concept in JAVA