9789391373849 Flipbook PDF


4 downloads 108 Views 2MB Size

Recommend Stories


Porque. PDF Created with deskpdf PDF Writer - Trial ::
Porque tu hogar empieza desde adentro. www.avilainteriores.com PDF Created with deskPDF PDF Writer - Trial :: http://www.docudesk.com Avila Interi

EMPRESAS HEADHUNTERS CHILE PDF
Get Instant Access to eBook Empresas Headhunters Chile PDF at Our Huge Library EMPRESAS HEADHUNTERS CHILE PDF ==> Download: EMPRESAS HEADHUNTERS CHIL

Story Transcript

BEGINNERS GUIDE TO JAVA PROGRAMMING

Dr. Marrynal S Eastaff Dr. V. Saravanan | Mrs. A. Gowri

Title

: BEGINNERS GUIDE TO JAVA PROGRAMMING

Author’s Name

: Dr. Marrynal S Eastaff Dr. V. Saravanan & Mrs. A. Gowri

Published by

: Shanlax Publications, Vasantha Nagar, Madurai – 625003, Tamil Nadu India

Publisher’s Address

: 61, 66 T.P.K. Main Road, Vasantha Nagar, Madurai – 625003, Tamil Nadu, India

Edition Details (I,II,III) : I ISBN

: 978-93-91373-84-9

Month & Year

: November, 2021

Copyright @

: Dr. Marrynal S Eastaff Dr. V. Saravanan & Mrs. A. Gowri

Pages

: 212

ACKNOWLEDGEMENT I wish to express my gratitude to my Lord Almighty and my family for having helped me in compiling this Book. I also wish to express my gratitude to the Management, CEO and Principal, Hindusthan College of Arts and Science for their constant support and encouragement. Dr. Marrynal S Eastaff Dr. V Saravanan Mrs. Gowri A

CONTENTS Chapter No. 1

Title Introduction to Object Oriented Programming 1. Introduction: 1.1 Object-Oriented Paradigm: 1.2 Basic Concepts of ObjectOriented Programming: 1.2.1 Objects and Classes 1.2.2 Data Abstraction and Encapsulation 1.2.3 Inheritance 1.2.4 Polymorphism 1.2.5 Dynamic Binding 1.2.6 Message Communication 1.3 Benefits of OOP 1.4 Applications of OOP 1.5 Java Features 1.5.1 Compiled and Interpreted 1.5.2 Platform Independence 1.5.3 Object Oriented 1.5.4 Robust 1.5.5 Security 1.5.6 Automatic Memory Management 1.5.7 Dynamic Binding 1.5.8 High Performance

Page No. 1-29 1 1 2 3 4 5 6 6 6 8 8 9 9 9 10 10 10 10 10 11

1.5.9 Multithreaded 1.5.10 Some Features in C/C++ Eliminated 1.6 How Java Differs from C and C++ 1.6.1 Java and C 1.6.2 Java and C++ 1.7 Java and Internet 1.8 Java and World Wide Web 1.9 Java Environment 1.9.1 Java Development Kit (JDK) 1.9.2 Application Programming Interface 1.10 Overview of Java Language 1.10.1 Simple Java Program 1.11 Java Program Structure 1.11.1 Document Section 1.11.2 Package Statement 1.11.3 Import Statements 1.11.4 Interface Statements 1.11.5 Class Definitions 1.11.6 Main Method Class 1.12 Java Tokens 1.13 Java Character Set 1.13.1 Reserved Keywords 1.13.2 Identifiers 1.13.3 Literals 1.13.4 Operators

11 11 11 11 12 13 13 14 14 16 17 18 20 21 21 21 22 22 22 22 23 23 24 24 24

2

1.13.5 Separators 1.14 Java Statements 1.15 Implementing a Java Program 1.15.1 Creating the Program 1.15.2 Compiling the Program 1.15.3 Running the Program 1.15.4 Machine Neutral 1.16 Java Virtual Machine(JVM) Data Types, Operators and Expressions 2. Introduction 2.1 Constants 2.1.1 Integer constants 2.1.2 Real Constants 2.1.3 Single Character Constants 2.1.4 String Constants 2.1.5 Backslash Character Constant 2.2 Variables 2.2.1 Rules for writing variable names 2.3 Data Types 2.3.1 Integer types: 2.4 Floating point types: 2.4.1 float: 2.4.2 double: 2.5 char: 2.6 Boolean: 2.7 Declaration of Variables 2.8 Giving Values to Variables 2.9 Assignment Statement

25 26 27 27 27 28 28 28 30-49 30 30 31 31 32 33 33 33 34 34 34 36 36 36 37 37 37 38 38

2.10 2.11 2.11.1 2.11.2 2.11.3 2.11.4 2.11.5

3

Read Statement Operators and Expressions Arithmetic operators Relational Operators Logical Operators Assignment Operators Increment and Decrement Operators 2.11.6 Conditional Operator 2.11.7 Bitwise Operators 2.11.8 Special Operators 2.12 Evaluation of Expressions 2.13 Type Conversions in Expressions 2.13.1 Automatic Type Conversion 2.13.2 Casting a Value 2.13.3 Generic Type Casting 2.14 Operator Precedence and Associativity Decision Making and Looping Statements 3.1 Introduction 3.1.1 Decision Making with if Statement 3.1.2 The If...Else Statement 3.1.3 Nesting of If...Else statement 3.1.4 The Else..if Ladder 3.1.5 Switch Statement 3.2 Decision Making and Looping

39 40 40 41 42 43 44 44 45 46 46 47 47 47 47 48 50-71 50 50 53 55 58 60 63

4

5

3.2.1 The While Statement 3.2.2 The do Statement 3.2.3 The for Statement: 3.2.4 Nesting of for Loops 3.3 Jumps in Loops 3.3.1 Jumping out of a Loop Classes, Objects and Methods 4.1 Classes, Objects and Methods 4.2 Defining a class 4.2.1 Fields Declaration 4.2.2 Methods Declaration 4.3 Creating Objects 4.3.1 Accessing Class Members 4.4 Constructors 4.5 Method Overloading 4.6 Constructor Overloading 4.7 Static Members 4.7.1 Static Methods 4.8 Nesting of Methods Inheritance 5. Inheritance: Extending a Class 5.1 Defining a subclass 5.1.1 Subclass Constructor / Super Keyword 5.2 Types of Inheritance 5.2.1 Single Inheritancce 5.2.2 Multi-level Inheritance 5.2.3 Multiple Inheritance

64 65 67 69 70 70 72-85 72 72 73 73 74 75 77 79 81 82 83 84 86-106 86 86 88 89 89 90 92

6

5.2.4 Multipath Inheritance 5.2.5 Hierarchical Inheritance 5.2.6 Hybrid Inheritance 5.3. Advantages of Inheritance 5.4 Disadvantages of Inheritance 5.5 Multilevel Inheritance 5.6 Method Overriding/ Overriding Methods 5.7 Abstract Methods and Classes 5.8 Final keyword 5.8.1 Finalizer Methods Arrays, Vectors and Strings 6. Arrays: 6.1 One-dimensional Arrays: 6.1.1 Java Array Declaration 6.1.2 Java Array Initialization 6.2 Two Dimensional Arrays 6.2.1 Initializing a Two Dimensional Arrays 6.3 Vectors 6.3.1 Vector Creation 6.3.2 Methods in Vector 6.4 Wrapper Classes 6.4.1 Converting Primitive Numbers to Object Numbers using Constructor Methods 6.4.2 Converting Object Numbers to Primitive Numbers using typeValue() method

93 95 97 99 99 99 101 103 105 106 107-128 107 107 108 108 110 111 112 113 113 116 116

117

6.4.3

7

Converting Numbers to Strings Using to String () Method 6.4.4 Converting String Objects to Numeric Objects using the Static Method Value of () 6.4.5 Converting Numeric Strings to Primitive Numbers Using Parsing Methods 6.5 Strings 6.5.1 String Methods 6.5.2 String Buffers Interface & Package 7. Interfaces 7.1 Defining an Interface 7.1.1 Extending Interfaces 7.1.2 Implementing Interfaces 7.2 Accessing Interface Variables 7.3 Packages: Putting Classes Together 7.4 Java API Packages 7.4.1 Using System Packages/Using Java API Packages 7.4.2 Creating Packages / User Defined Packages 7.4.3 Using a Package 7.5 Visibility and Access Rights in Java 7.6 Adding a Class to a Package 7.7 Hiding Classes

117 117

118

120 120 125 129-147 129 129 130 132 135 136 138 140 141 142 144 145 146

8

9

Threads in Java 8.1 Multithreaded Programming 8.2 Threads in Java 8.3 Creating Threads 8.3.1 Extending Thread class 8.3.2 Implementing Runnable Interface 8.4 Stopping and Blocking a Thread 8.5 Life Cycle of Thread 8.5.1 Thread Methods 8.6 Thread Priority 8.7 Synchronization Exception Handling & Applet Programming 9. Managing Errors and Exceptions 9.1 Types of Errors 9.2 Exceptions 9.3 Multiple Catch statements 9.4 Using Finally Statement 9.5 Throwing our Own Exception 9.6 Applet Programming 9.7 How Applets Differ from Applications 9.8 Applet Life Cycle 9.8.1 Initialization State: 9.8.2 Running state 9.8.3 Idle or Stopped state 9.8.4 Dead state 9.8.5 Display State 9.9 Creating an Executable Applet

148-165 148 149 151 151 154 157 158 159 161 163 166-189 166 166 167 169 170 172 174 174 175 176 176 177 177 178 178

10

9.10 Applet Tag 9.11 Passing Parameters to Applets 9.12 Getting Input from User 9.13 Graphics Programming 9.13.1 The Graphics Class 9.13.2 Lines and Rectangles 9.13.3 Circles and Ellipses 9.13.4 Drawing Arcs 9.13.5 Drawing Polygons Managing Files 10. Managing Input/Output Files in Java 10.1 Concept of Streams: 10.1.1 Stream Classes: 10.1.2 Byte Stream Classes 10.1.3 Character Stream Classes 10.2 Other useful I/O classes 10.2.1 Using the File Class 10.3 Creating a File

179 182 183 184 184 185 186 187 188 190-198 190 190 191 191 194 196 196 197

Beginners Guide to Java Programming

CHAPTER 1 Introduction to Object Oriented Programming 1

Introduction:  Java is an object oriented language developed by Sun Microsystems.  Around 1990 James Gosling, Bill Joy and others at Sun Microsystems began developing a language called Oak.  Oak language was primarily developed to control microprocessors embedded in consumer items like PDA’s for this language should be a platform independent, reliable and compact language.  But however due to the sudden explosion of Internet and similar technologies, Sun Microsystems changed their project objectives and renamed the Oak language into Java.  In 1994 the project team developed a web browser called “HotJava” capable of locating and running applets, a java program that can run on a web browser.

1.1 Object-Oriented Paradigm:  The major objective of object-oriented approach is to eliminate some of the flaws encountered in the procedural approach  OOP treats data as a critical element in the program development and does not allow it to flow freely around the system.  It ties data more closely to the functions that operate on it and protects it from unintentional modification by other functions. ISBN: 978-93-91373-84-9

1

` 350 ISBN 939137384-4

9 789391 373849

Get in touch

Social

© Copyright 2013 - 2024 MYDOKUMENT.COM - All rights reserved.