Chapter2_OverviewOfJava

20
UNIT- I CHAPTER IN BOOK- 2 OVERVIEW OF JAVA -K. Indhu

description

java

Transcript of Chapter2_OverviewOfJava

UNIT- ICHAPTER IN BOOK- 2OVERVIEW OF JAVA

-K. Indhu

K. INDHU 2

SYLLABUS COVERED HERE• Overview Of Java

K. INDHU 3

GOALS1. Introduction2. OOP (Encapsulation) in Java3. OOP (Inheritance) in Java4. OOP (Polymorphism) in Java5. Getting Started with Java Program6. Compiling Java Program7. Creating & Compiling Java Application8. Executing Java Application9. Comments in Java10. Block of a Program11. Second Short Java Program12. main() Method in Java13. Third short Java Program14. Java Lexical Issues

K. INDHU 4

INTRODUCTION• Two Paradigms-> (i) Process Oriented Model,• (ii) Object Oriented Model.

• The process-oriented model can be thought of as code acting on data.

• C implements process-oriented model.

• An object-oriented model can be characterized as data controlling access to code.

• C++, Java implements object-oriented model.

K. INDHU 5

OOP (ENCAPSULATION) IN JAVA

K. INDHU 6

OOP (INHERITANCE) IN JAVA

K. INDHU 7

OOP (POLYMORPHISM) IN JAVA

K. INDHU 8

GETTING STARTED WITH JAVA PROG.1. Write a Simple Java Application,2. Save the Java Application as-> “Example.java”,

3. Compile the Java Application,

4. Run / Execute the Java Application.

K. INDHU 9

GETTING STARTED WITH JAVA PROG.• The Java compiler requires that a source file use the .java filename

extension.

• The name of that class (in the code snippet) should match the name of the file that holds the program.

• Make sure that the capitalization of the filename matches the class name.(The reason for this is that Java is case-sensitive.)

K. INDHU 10

COMPILING JAVA PROGRAM

K. INDHU 11

CREATING & COMPILING JAVA APPLN.

K. INDHU 12

EXECUTING JAVA APPLN.

K. INDHU 13

COMMENTS IN JAVA• (1) int i = 10; // i is used as a counter

• (2) THE MULTILINE COMMENT • This form of comment may also extend over several lines as

shown here:• /*• This is a longer comment• that extends over • five lines. • */ P• (3) This is the documentation comment. • /**• This is a Java documentation comment.• */

K. INDHU 14

BLOCK OF A PROGRAM• A pair of braces ( {...........} ) in a program forms a block that

groups components of a program.

K. INDHU 15

SECOND SHORT JAVA PROGRAM

K. INDHU 16

main() METHOD IN JAVA• The main method provides the control of program flow. The Java

interpreter executes the application by invoking the main method. • • The main method looks like this->• public static void main(String[] args)• {• // Statements;• }

K. INDHU 17

THIRD SHORT JAVA PROGRAM

K. INDHU 18

JAVA LEXICAL ISSUES

K. INDHU 19

SO FAR WE STUDIED…• Overview of Java

HAPPY LEARNING!!!