Ce diaporama a bien été signalé.
Nous utilisons votre profil LinkedIn et vos données d’activité pour vous proposer des publicités personnalisées et pertinentes. Vous pouvez changer vos préférences de publicités à tout moment.

Learn java in hindi

2 789 vues

Publié le

Learn java in hindi, java in hindi, java hindi pdf, java tutorial in hindi,

Publié dans : Ingénierie
  • Soyez le premier à commenter

Learn java in hindi

  1. 1. w w w . b e s t h i n d i t u t o r i a l s . c o m 2015 Java in Hindi Third Edition By Prof. V.K. Sharma www.besthinditutorials.com
  2. 2. Java in Hindi Third Edition V.K. SHARMA www.besthinditutorials.com
  3. 3. ©Copyright 2015 by www.besthinditutorials.com This EBook may not be duplicated in any way without the express written consent of the publisher, except in the form of brief excerpts or quotations for the purpose of review. The information contained herein is for the personal use of reader and may not be incorporated in any commercial programs, other books, databases, or any kind of software without written consent of the publisher. Making copies of this EBook or any portion thereof for any purpose other than your own is violation of copyright laws. This edition has been published by www.besthinditutorials.com Limits of Liability/disclaimer of Warranty: The author and publisher have used their best efforts in preparing this EBook. www.besthinditutorials.com makes no representation or warranties with respect to the accuracy or completeness of the contents of this book, and specifically disclaims any implied warranties which extend beyond the descriptions contained in this paragraph. No warranty may be created or extended by sales representatives or written sales materials. The accuracy and completeness of the information provided herein and the opinions stated herein are not guaranteed or warranted to produce any particular results and the advice and strategies contained herein may not be suitable for every individual. www.besthinditutorials.com shall not be liable for any loss of profit or any other commercial damages, including but not limited to special, incidental, consequential, or other damages. Trademarks: All brand names and product names used in this EBook are trademarks, registered trademarks, or trade names of their respective holders. www.besthinditutorials.com is not associated with any product or vendor mentioned in this EBook. Reprint Edition: 2013 Published By: www.besthinditutorials.com
  4. 4. Contents 1. Introduction to Java 1.1. History of java 1.2. Features of java 1.3. OO principles of java 1.4. Java vs. c and c++ 2. Installing Java 2.1. Java development tools 2.2. Downloading java 2.3. Installing java and setting environment variables 2.4. Download eclipse 2.5. Installing eclipse 3. First Java Program 3.1. Running a java program 3.2. Hello world program 4. Data Types 4.1. What are data types? 4.2. Integer 4.3. Float 4.4. Character 4.5. Boolean 5. Variables 5.1. What are variables? 5.2. Types of variables 5.3. Creating variables 6. Strings 6.1. What are strings? 6.2. Operations on strings 7. Arrays 7.1. What are arrays? 7.2. Creating an array 7.3. Initializing an array 7.4. Displaying an array 8. Operators 8.1. What are operators?
  5. 5. 8.2. Types of operators 9. Control Statements 9.1. What are control statements? 9.2. Types of control statements 10.Classes 10.1. What are classes? 10.2. Advantages of classes 10.3. Creating a class 11.Objects 11.1. What are Objects 11.2. Steps to create an object 12.Construtors 12.1. What are constructors? 12.2. Rules for creating constructors 12.3. Types of constructors 13.Methods 13.1. What are methods? 13.2. Structure of method definition and method call 14.Inheritance 14.1. What is inheritance? 14.2. Types of inheritance 14.3. Inheriting a class 14.4. Example 15.Exception Handling 15.1. What are exceptions? 15.2. Keywords(try, throw, catch) 15.3. Example 16.Interfaces and packages 16.1. What are interfaces? 16.2. Example 16.3. What are packages? 16.4. Creating a package 16.5. Using a package 16.6. Some common java packages 17.Multithreading 17.1. What is multithreading? 17.2. Thread class 17.3. Runnable interface
  6. 6. 17.4. Synchronization 18.File I/O 18.1. What are streams? 18.2. Byte streams 18.3. Character streams 19.Serialization 19.1. What is serialization? 19.2. Serializable interface 20.Collections Framework 20.1. Collection interface 20.2. Other interfaces 21.Lambda Expressions 21.1. What is functional interface? 21.2. What is lambda expression? 22.Generics 22.1. What are generics? 22.2. Generic classes 22.3. Generic methods 23.Event Handling 23.1. Introduction to Event Hanlding 23.2. Different types of events 23.3. Example 24.Applets 24.1. What are applets? 24.2. Applets life cycle methods 24.3. Example 25.AWT(Abstract Windows Toolkit) 25.1. What is AWT? 25.2. Container classes 25.3. Component classes 25.4. Frame class 26.Swing 26.1. What is swing? 26.2. Features of swing 26.3. Swing classes 26.4. Example 27.Servlets 27.1. Architecture of servlets
  7. 7. 27.2. Life cycle of servlets 27.3. Example 28.Index
  8. 8. Preface The idea of writing a book about Java Development in Hindi can be somewhat futile at times, considering the pace at which Java continues to expand, morph and change. What started out as a book project two years ago has now become a series of updates to the original work with the page count nearly double the original project and that after making hard decisions about what to leave out of the book to make sure it gets liked. This update to Java in Hindi represents our latest effort to provide coverage on important Java Development topics, namely the expansion into the Swing. Like many things in life, the only constant is change, but by now we are somewhat accustomed to the rapid-fire environment of Java Development. To the end, we have ensured that all the programs work with eclipse as well as without eclipse. The third edition is written by Vipin Kumar Sharma. Thank you for learning and collaborating with us. VIPIN KUMAR SHARMA
  9. 9. Acknowledgement Writing a third edition of Java in Hindi feels somewhat like the old saying about weddings: “Something old, something new…” The deadline for the third edition did not become any easier as at last count there are still only 24 hours in the day. And as for something new it seems as though Java’s pace of innovation is continuing to match its adoption rate by users around the globe. In particular, we’d like to acknowledge and thank everyone at www.besthinditutorials.com. Firstly I would like to thank our EBook Designers and editors, who have been involved in every aspect of now three editions of this project. I would also like to thank our publisher to bring this masterpiece in EBook format.
  10. 10. About this book Java in Hindi, Third Edition is a revision and update of the second edition published in 2013. This third edition adds new content related to java 8. Like its predecessors, this book covers important beginner topics such as “What is Java?” and installing and using the development environment. We than advance to practical working examples of core programming topics any developer will be happy to have at the ready on the reference shelf. The remaining chapter’s present detailed example applications covering advanced topics, including AWT and Swing. Although you can read the book from start to finish, you can also consider it a few books in one. If you are new to Java focus first on beginning chapters. With the foundation you can work your way up to last chapter. Who should read this book? We wrote this book for professional programmers and hobbyists alike. Many of the concepts can absorbed without specific Java language knowledge. If you have c, c++ or c# knowledge, you will be able to follow the examples. Prior eclipse experience is helpful, but not required. A number of good resources are available on java and eclipse to augment the content of this book. And lastly the person who is willing to learn java in his mother tongue Hindi should read this book. Road map 1. Basic – first 10 chapters contain basic information regarding java programming. 2. Intermediate – next 10 chapters are somewhat of intermediate level and necessary java topics. 3. Advanced – remaining chapters covers some advanced topics of java language.
  11. 11. Chapter 1 Introduction This chapter covers:  History of Java  Features of Java  OO Principles  Java vs. c and c++ History of java Java एक general purpose object oriented programming Sun Micro-systems java 1991 U.S. Java क oak क change क क java क Java James Gosling develop क Java क consumer electronics क TV, VCR software क ए develop क Java क important औ popular feature क java platform independent क java क एक particular hardware operating system क ए Java ए program क system execute क क Java क feature java क popular
  12. 12. Features of java Java क features एक java programmer क ए क features ए java क क popular features क क क Compiled and interpreted programming languages compiled interpreted क java approaches क combine क औ एक two stage system java क program क compiler क क byte code generate क Byte code machine instructions ए java second stage byte code क interpret क क machine code generate क , directly execute क क Platform independent Java क byte code platform independent क java program क compile क byte code convert byte code क operating system क JVM (Java Virtual Machine) Java क program क run क क ए क operating system JVM install क operating system क ए JVM क क एक क औ क उ operating system क ए byte code क machine code convert क ए क एक operating system क JVM generate क byte code क JVM run क क औ JVM उ operating system क ए machine code generate क ए machines क ए machine code generate क एक byte code generate क क program byte code convert Object oriented Java एक true object oriented programming language Java almost क object Java क information objects क store
  13. 13. Robust and secure Java एक robust language Java क program environments technologies क crash ए क क क Java programs क crash reliable language Java security JVM क provide क Machine code generate क JVM क tests क क invalid combinations क detect क Distributed Java distributed applications ए क क Distributed applications applications networks औ एक क task perform क Java RMI क through network available applications interact क क Simple and familiar Java एक simple language Java क features c औ c++ ए ए Java क syntax c औ c++ क क variable declarations, control statements औ method declarations java क easy understand क java c औ c++ क क ए programmers क familiar Multi-threaded and interactive Java एक multi-threaded language क java program एक क tasks complete क क feature java क fast औ interactive High performance Java क performance impressive Java क speed क main reason byte code Java क architecture design क क java run time over head क Dynamic and Extensible Java एक dynamic language Java run time क libraries, methods औ classes dynamic linking क Java क technologies क क क
  14. 14. Ease of development Java programs develop क easy Java क built libraries provide क क क ए important classes programmer क overhead क Programmer libraries क access क क software develop क क Object oriented principles of java क क java एक object oriented language Java object oriented programming languages क object oriented principles क follow क principles क क क Encapsulation Encapsulation क data hiding क Encapsulation private variables declare क औ उ public methods क through access क क variables क क class क methods access क क क class क variables क access क क क data क hide क औ क Encapsulation क एक औ data औ code क एक unit bind क औ access क क क क variables औ methods एक unit bind Java 3 level क data hiding provide क  public - क public class members क classes access क क  private - क private class members क क class access क क  protected - क क class क inherit क class क class members क access क क
  15. 15. Inheritance principle क through एक class क variables क class access क क क क एक methods क क computer क memory औ programmer क time Java multiple inheritance allow एक class एक class क inherit क क क interfaces क through क Polymorphism Polymorphism क "एक औ क क " Polymorphism क through एक interface situation एक according actions क क method overloading क Abstraction Abstraction java क important concept क क क bike क क क उ उ क internal working क Abstraction क same concept software क internal working क क क interface provide क क interact क Java development tools Java software क built in development tools क development tools क क क JDK(Java Development Kit) JDK एक environment क java program ए क क औ उ क execute क क JDK JRE क java program क execution क ए responsible JRE(Java Run-time Environment)
  16. 16. JRE क program क execution क ए responsible JRE क classes औ libraries क group एक क program क execute क ए environment ए क JRE क 2 क 1. Program main क 2. Program क execution start क JVM (Java Virtual Machine) क क क java program क compile क byte code convert क byte code machine code convert क JVM एक environment machine byte code क machine code convert क JRE क क क क
  17. 17. Chapter 2 Installing Java This chapter covers:  Java development tools  Installing java and eclipse Installing java Java 2 क क एक command prompt version उ क क क java औ क editor क क क औ command prompt उ क क क क IDE उ क क एक environment क उ क क क official क NetBeans IDE क Eclipse उ क क Java command prompt platform औ NetBeans IDE उ क क http://www.oracle.com/technetwork/java/javase/downloads/index.html
  18. 18. Installing eclipse Eclipse IDE उ क क - http://www.eclipse.org/downloads/packages/eclipse-ide-java-ee-developers/marsr
  19. 19. Chapter 3 First Java Program This chapter covers:  Running a java program  Hello world program Running a java program क क क क 2 क . java IDE क use क notepad औ console उ क . क console क क क क ए 1. Through IDE (Integrated Development Environment) 2. Through Console Through IDE IDE क क क क क औ क क . IDE क Eclipse, NetBeans क . क क IDE Java Compiler क execute क . क क एक IDE उ क .
  20. 20. Through Console Console program क क steps ए ए . 1. Run cmd क औ command prompt ओ क 2. Command prompt ओ क क उ drive install औ क bin folder क locate क
  21. 21. 3. क क क ए क क क क क ए javac क क औ enter क क क image क 4. क उ .java extension क MyProgram.java. क क prompt javac command क औ क क javac MyProgram.java औ enter क क क errors ए क क executable file ए क .
  22. 22. 5. java क क क औ ए क java MyProgram. क
  23. 23. Hello world program एक simple क क क क lecturer board औ क क copy क औ क ओ एक simple notepad क औ उ क क java program क क How to run a java program tutorial क एक message क inverted commas (" ") क एक ए क HelloJava औ main println क क क क क क औ , ए description क क public - public एक access modifier Access modifiers 3 क (public, private, protected) औ क members क ए क क क क क tutorials class - एक क ए क क क क important concept क क Class क
  24. 24. HelloJava - क क क ए static - keyword क method क क क क क ए क क क क main क java run time environment program क execute क क ए access क main - एक क क execution उ main String args [] - string array command line arguments क ए क क execute क argument क क System.out.println () - system एक package , out एक , औ println एक , command prompt screen उ क क ए क
  25. 25. Chapter 4 Data Types This chapter covers:  What are data types?  Integer  Float  Character  Boolean Introduction to java data types Data, data औ data. Computer क data data??. Data क क available क क क उ उ क Data type क क data औ क क data क category क क ??. क data operations perform क क operations(Addition, Subtraction, Multiplication and Division) क perform क क क क perform क क क variable ए क उ क क data store क define क data type क Java data types क 4 categories define क
  26. 26. Integers Integers complete number numbers fractional part ( औ उ क क ) include क क Integers क उ क size क according 4 categories define क क Type Explanation Example Byte Byte क size 8 bit -127 क 128 क क क value byte store क क byte age = 40; Short Short क size 16 bit Short -32,768 क 32,767 क क क value store क क short salary = 25000; Int Int क size 32 bit Int -2,147,483,648 क 2147483747 क क क store क क int population =2,00,000 Long Long क size 64 bit value store क क long worldpop = 8000000000 Floating point numbers Floating point numbers numbers fractional part ( औ उ क क ) क represent क क important mathematical calculation क numbers क Floating point numbers क 2 categories define क क Type Explanation Example Float Float single precision value क represent क Float क size 32 bit Float 1.4e-045 क 3.4e+038 क क value store क क Float क क एक value represent क float temp = 34.4;
  27. 27. Double Double double precision value क represent क Double क size 64 bit Double 4.9e-324 क 1.8e+308 क क value store क क Double क 7 value क store क क double pi = 3.1416; Character क एक क store क क ए character क Character क size 16 bit Character क char keyword represent क Example - char FavLang = 'c'; Boolean Boolean data types क logical decision store क क ए क Boolean variables क 2 values true false Example - boolean isFiveMoreThanOne = true;
  28. 28. Chapter 5 Variables This chapter covers:  What are variables?  Types of variables  Creating variables Introduction to java variables क information क store क क ए variables क उ क औ उ information क उ variable क value क information क क , क क क औ उ क उ store क क ए क 2 variables क एक variable उ क store क औ variable उ क उ store क क variable क value changeable क value store क क variables क value change क क constants क Information क store क क variables क create क Variable ए क क ए variable क variable क unique ए compiler error generate क variable क क datatype define क Data type information type क क क क information store क क क store क क store क क store
  29. 29. क Variable क क क store क data type क Types of variables Java variables क उ क scope क 2 types क Local variables क method क variable ए क उ variable क उ method क उ method क variable क क उ variable क scope क variables क scope क method क उ local variables क Global variables क क variable program क उ क method declare क variables क program क starting declare क variables program क क क variables program global variables क Global variables क scope program Creating variables in java Java variables ए क क 2 stages क क क Variable declaration stage variable क औ क क values store क define क Example - int personAge; // data type and variable name Variable initialization stage variable क value define क Example - int personAge = 26;
  30. 30. क एक क क Example - int personAge = 26; क variable क value run time (dynamically) user input क variable क initialize क declare क क first stage Taking input from user Run time variable value input क क ए Scanner class क object create क class क क क methods provide क keyboard input क क ए क क data type क ए methods provide क ए Object ए क उ argument System.in क System.in क क keyboard type क Value read क क ए object methods क क क integer value read क क ए nextInt(), string क ए nextLine() औ float value read क क ए nextFloat() methods call क क Example int PersonAge; // variable declaration Scanner s = new Scanner(System.in); // Scanner class object PersonAge = s.nextInt(); // reading from keyboard
  31. 31. Chapter 6 Strings This chapter covers:  What are strings?  Operations on strings Introduction to java strings Strings characters क sequence क "Java in Hindi" एक string Java strings क objects क implement क ए क , क strings operations perform क क Operations क 2 strings क compare क strings perform क क String एक class normal string variables create क क औ string class क object create क क औ क operations perform क क String myString = "this is a string"; // variable String myString = new String("This is a string"); // object String क एक variable क औ एक object क क क string क object क क एक object create क उ क change क क उ क ए ऊ ए ए example क myString object क क text "This is a
  32. 32. string" क change क क ". क string क variable क क उ changes क क Java क methods provide क , string object modification क क क क एक string object generate Original string object क change operations क String length क string characters उ string क length क string क length क क ए length() method क क क ए उ string length method call क String myString = "hello"; System.out.println(myString.length()); Concatenating strings क 2 strings क क एक string उ string concatenation क + operator क क क औ concat() method क क क क क उ ए String myString = "This is a string"; String yourString = "This is your string"; String ourString = myString+yourString; // with + operator ourString = myString.concat(yourString); // with concat() method System.out.println(ourString);
  33. 33. String indexing with charAt() method string क एक method क extract क क ए क Strings क indexing arrays क character 0 index ए string क क single character क access क क क ए charAt() method क index number method pass क method उ index क character क return क String myString = "hello"; System.out.println(myString.charAt(3)); String indexing with substring() क string sub string search क क ए substring() method क method 2 arguments pass क argument index number string क access क औ argument index number क क string access क method starting index क ending index क क string return क String s1 = "hello my name is khan"; System.out.println(s1.substring(5,8)); String indexing with indexOf() क sub string क index क क ए indexOf() method क method एक sub string pass क method उ sub string क stating index return क String s1 = "hello my name is khan"; System.out.println(s1.indexOf("my")); //returns 7
  34. 34. String comparison with equals() क 2 strings क compare क क ए Equals() method क strings equal method true return क एक string method क call क औ string argument क pass क क उ String s1 = "hello"; String s2 = "hello"; System.out.println(s1.equals(s2)); // prints true
  35. 35. Chapter 7 Arrays This chapter covers:  What are arrays?  Creating an array  Initializing an array  Displaying an array Introduction to java arrays क क क 200 employees क क information store क employees क information separately store क क ए क 200 variables क क क क human variables क create औ manage क क क 200 औ क program क क ए arrays क उ क एक array similar data type क values क collection Array similar information क group क employees क salary क array क employees क salary store क क क type क array create क क क int, float, char type क variable create क उ क values उ क array create क उ क size define क array क size उ values उ store क क Array values क indexing क store क index एक different variable क represent क
  36. 36. Arrays क index zero ए क array क size n last element (n -1) position store Elements 4 6 9 10 22 Index 0 1 2 3 4 array क size 5 क array क last element 22 4th position store क array क index zero Creating java arrays Java arrays create क क class क object create क क उ type arrayName = new type[arraySize]; array_name[0]; // first variable array_name[1];// second variable .. .. array-name[n-1]; // last variable
  37. 37. type type type क array create क arrayName array क unique ए new Array क memory allocate क क ए new keyword क arraySize array क size क integer define क क array क elements store क int salary = new int[10]; Initializing arrays Arrays क 2 initialize क क क variable क java क क index क initialize क क क उ salary[0] = 25000; salary[1] = 10000; .. .. salary[9] = 30000; क values input क क
  38. 38. Scanner s = new Scanner(System.in); salary[0] = s.nextInt(); क time consuming क एक loop क औ values क एक input क Scanner s = new Scanner(System.in); for(int i=0;i<10;i++) { salary[i] = s.nextInt(); } Displaying arrays Arrays क values 2 print क क single index क value print क क औ array क print क क System.out.println(salary[0]); // prints value of first index
  39. 39. for(int i =0; i<10; i++) { System.out.println(salary[i]); // prints all array } Multidimensional java arrays क array क example one dimensional array Arrays क क dimensions क 2 dimensional arrays क क Two dimensional arrays create क क ए row औ column size क table create क square brackets rows क औ brackets columns क represent क Creating two dimensional array int TwoDiem [][] = new int [3][4]; Initializing two dimensional arrays Scanner s = new Scanner(System.in); System.out.println("Enter the array elements"); for(int i=0; i<3;i++) {
  40. 40. for(int j=0;j<4;j++) { TwoDiem[][] = s.nextInt(); } } Displaying two dimensional arrays for(int i = 0; i<3; i++) { for(int j=0; j<4; j++) { System.out.println(TwoDiem[i][j]); } } Java arrays implement क java arrays क problem comments mention क क
  41. 41. Chapter 8 Operators This chapter covers:  What are operators?  Types of operators Introduction to java operators क operators क उ variables operations perform क क ए क data type operations perform क ए operators Operators unary औ binary 2 क क Operators क variables क operand क Unary operators एक operand क apply औ binary operators 2 operands apply Java 6 type क operators 1. Arithmetic operators 2. Logical operators 3. Bit wise operators 4. Relational operators 5. Assignment operators
  42. 42. 6. Conditional operators operators क Arithmetic operators Arithmetic operators mathematical computation perform क क ए क Arithmetic operators 5 type क क Operator Explanation Example Addition (+) Addition operator 2 values क add क क ए क a+b Subtraction (-) Subtraction operator एक value value क subtract क क ए क a-c Multiplication(*) Multiplication operators 2 variables क values क multiply क क ए क a*b Division(/) क एक variable क क variable क क ए division operator क a/b Modulus(%) क क modulus operator क a%b Logical operators Logical operators boolean values operations perform क क ए क operators 3 क क operations variables क value true false क Logical operators क
  43. 43. Operator Explanation Example Logical AND (&&) क operators क variables क value true result true false a&&b Logical OR (||) क operator क variables क एक value true result true a||b Logical NOT (!) एक unary operator variable क क उ variable क value क उ क !a Bit-wise operators Bit-wise operators bit by bit operations perform क क ए क operators variables क values क bits convert क क उ operations perform क Bit wise operators 4 क क Operator Explanation Example Bit wise AND (&) operator क 2 variables क क उ क common bits क result variable copy क a&b Bit wise OR (|) operator क 2 variables क क उ क uncommon bits क result variable copy क a|b Left shift (<<) operator क क variable क value क bits a<<b
  44. 44. convert क क उ क bits क left shift क क bits क क variable क right Right shift (>>) variable क क variable क value क bits convert क क उ क values क right shift क क bits क shift क variable क right a>>b Relational operators Relational operators 2 variables क relation क क ए क क if statement क operators क 2 variables क relation क क variables एक औ एक Operator Explanation Example Equal to (==) variables equal result true a==b Not equal to(!=) variables एक क equal result true return a!=b Greater than(>) left side क variable right side क variable result true a>b Less than(<) left side क variable right side क variable result true a<b Greater than equal to (>=) left side क variable right side क variable उ क result true a>=b
  45. 45. Less than equal to (<=) left side क variable right side क variable उ क result true a<=b Assignment operators Assignment process क simple औ fast क ए java क assignment operators provide क क Operator Explanation Example Simple assignment (=) operator right value क value left variable क assign क a=b; Plus assignment (+=) operator left औ right variables क value क add क क left variable store क a+=b; Minus assignment(-=) operator left side क variable क value right side क variable क value क result left side क variable store क a-=b Multiply assignment(*=) operator left औ right side क variables क values क multiply क क result left side क variable store क a*=b Divide assignment(/=) operator left side क variable क value क right side क variable divide क क result left side क variable store क a/=b
  46. 46. Conditional operator (?:) Conditional operator java क special operator if statement क क क ternary operator क variables conditions क according values store क क ए क operator ? एक condition , condition true colon value colon क value variable store Example a=5, b=3; c= a>b?a:b; // c a क value store क ए
  47. 47. Chapter 9 Control Statements This chapter covers:  What are control statements?  Types of control statements Introduction to control statements क क उ क क ए क क उ क क condition क उ औ क क condition क क action क control क क condition based क program उ क statements क execution क क condition क control क क औ condition statements execute क उ execute क क क एक उ क Gmail क website id औ password email औ password check क क email औ password email password क account औ email password क एक message show क क control statements क क Control statements statements program क execution (flow) control क क statements क execute control statements क क Java क pass 3 क control statements selection statements एक statement क condition
  48. 48. क according select क क execute क Iteration statements क क statements क execute क क औ jump statements program एक क क क क क Types of control statements क control statements क Selection statements Selection statements क statement क condition check क क select क क execute क condition true क statements क execute क औ condition false क statements क execute क Selection statements 3 क क क IF statement IF statement क ए if keyword क क keyword क brackets condition condition variables related क औ क normal condition क Condition क statements क block Condition true statements execute औ condition true if block skip क int a =5, b = 3; if(a>b) { System.out.println("A is bigger than B"); }
  49. 49. IF ELSE statement IF ELSE statements IF statements क क IF ELSE statements condition false क statements क execute क क int a = 5, b = 3; if(a>b) { System.out.println("A is bigger than B"); } else { System.out.println("B is bigger than A"); } Switch statement Switch statements switch keyword क ए एक condition pass क औ cases ए ए case condition match क case execute क क variable क value 3 case क statements execute क क क क क case condition match क situation default case execute Switch(2) { case 1: //this will not be executed Break;
  50. 50. case 2: // this will be executed Break; Default: //this will not be executed because case matched. } Iteration statements क क क एक statement क execute क क Iteration statements क statements क execute क क क condition true Condition false execution क क variable क value print क क क ए क print statements क क एक iteration statement औ क statement क क execute क Iteration statements एक statement क execute क क क looping statements क 3 क क For Loop For loop loops simple औ क loop For loop क structure क for(initialization;condition;increment) { //statements }
  51. 51. For loop क initialization part एक variable क initialize क क value integer क loop क starting point variable क value loop क variable क condition include क loop execute क For loop क condition part loop क condition condition क loop terminate condition loop infinite क क condition true क loop Condition false loop terminate Increment part initialized variable क increment क क loop क execution ढ़ क औ condition उ execute क terminate variable क increment क क ढ़ class IterSta { public static void main(String args[]) { for(int i=1; i< = 10; i++) { System.out.println("Numbers form 1 to 10 "); System.out.println(i); } }
  52. 52. While loop While loop for loop While loop initialization statement loop क Brackets क condition औ increment part block क Increment part क statements क class WhileStat { public static void main(String args[]) { int i = 1; while(i<=10) { System.out.println(i); i++; } } While loop क feature क क variable initialize क क loop क terminate क क ए क condition क क क program क variables related क condition क While loop क statements क initialize क क क क for loop क क क
  53. 53. Do - While loop For औ while loop statements execute condition true क statements क execute condition check क do-while loop एक statements execute उ क condition check क एक Condition true false एक क loop statements execute क check क condition true loop continue क terminate class doWhileStat { public static void main(String args[]) { int i = 0; do { System.out.println(i); i++; }while(i<=10) } } Jump statements Jump statements program एक क क क Break statements
  54. 54. Break statement क statement क sequence क break क क ए क क क break statements क switch statements exit क ए क switch cases break statement क cases क statements execute loop exit क क loop क ए एक break statement औ loop exit break; Continue statement क क क क loop क क iteration क execute क condition उ iteration क skip क क ए continue statement क क क 1 100 क क number print क number ए 2 क multiple क क ए 1 100 क loop ए औ loop क check क क number 2 divide number 2 divide continue statement execute औ iteration skip ए औ next iteration automatically ए continue; Return statement Return statement क method क return क क ए क क क value return क statement method definition last method क program उ method method क एक return statement औ एक value return क क return;
  55. 55. Chapter 10 Classes This chapter covers:  What are classes?  Advantages of classes  Creating a class Introduction to java classes Java क class class? औ java क class क क क क class एक type क data types class type क variables create क क क class type variables objects क Class क variables औ functions क group structure create क औ उ एक identify क structure क base क object create क क Class एक entity औ उ related attributes क class क क क information store क represent क क ए क क variables क क क , उ , औ क क क क 100 क information store क situation क 100*4=400 variables create क एक क ए classes क introduce क Class क 4 variables क एक type create क क औ उ type क 100 objects create क क Object क class क variable क access क क value assign क क क उ
  56. 56. class Person { String name; int age; int phone; String address; } एक java program क classes create क क क main method एक class Main method program क execution start Advantages of classes ढ़ क classes क advantages Security क variables औ methods classes Classes 3 level क access protection provide क क क क क class members क access क क Reduce complexity Classes क क variables औ methods क Classes क program simple औ उ क complexity Separation क program क क क क data data operations perform क methods क perform क Classes क क ए एक type क
  57. 57. data औ उ related operations (methods) क type क data औ उ related operations (methods) separate क क क data क ए class क क क उ data perform operations (methods) उ class create क क क program क manage क क एक class purchases क information store क क ए औ class sales क information store क क ए क Focus on data classes क program क focus data data क ए methods create क औ data क hide क Classes data focused approach क useful software क ए Creating a class Class create क क ए class keyword क क Class keyword क class क क program एक क classes class क unique ए class main method class public declare क ए Class create क क उ class Person { String Name = "Vipin"; int age = 24; public void display() {
  58. 58. System.out.println("Name is "+Name+"Age is"+age); } public static void main(String args[]) { this.display(); } } ऊ ए ए उ person क एक class create क class name औ age 2 variables display() method declare क Main method display() method क call क Main method क program एक क classes क क main method एक class program main method program क execution start class main method उ public declare क necessary Main method क public declare क ए क ए क classes methods by default private औ main method क public declare क java run time environment क main method क access क औ क program क execution start क class क क method क access क क ए objects क Java run time environment क main method क object क access क क ए main method क static declare क
  59. 59. क necessary terms क क क Instance variables/methods variables औ methods class क object access क उ instance variables methods क Static variables/methods Static variables औ methods क objects क access क क क variable method क static क ए static keyword क Static members क access क क ए class क क (.) operator क उ member क Command line argument Main method क parameters क string array command line argument क ए क Command line arguments arguments program क run क क क क program run क argument क क program उ arguments क according run क
  60. 60. Chapter 11 Objects This chapter covers:  What are objects?  Creating objects Introduction to java objects integer एक type class एक type Class type create क क ए क object create क Class क variables औ methods उ class क access क क ए क उ class क object create क Object create क क उ class क variables क access क क औ methods क call क क Objects create क क ए new keyword क उ क Objects create क क क steps ए 1. class क object create क उ class क 2. Class क क object क object क unique ए 3. क equals (=) operator 4. क new operator 5. New operator क class क औ उ क brackets क semicolon
  61. 61. Example class Person { String Name="Vipin"; int age=24; public void display() { System.out.println("Name is "+Name+ "Age is"+age); } } class PersonObj { public static void main(String args[]) { Person p1 = new Person(); p1.display(); } }
  62. 62. ऊ ए ए example 2 classes क program क execution उ class start PersonObj class start class person class क object create क Person class क object create क क उ class क object क (.) dot operator क display method क call क object उ class क क member (variable method) public access क क क object create क उ class क constructor call Class क क brackets ए class क constructor क call क objects क variables क 2 parts create क क part object क declare क औ part initialize क Example Person p; p1 = new Person(); objects क create क क initialize क reference variables क Example Person p1; This keyword This keyword current object क represent क Current object क currently class क क औ उ class उ class क object क क This keyword क
  63. 63. क this keyword उ situation क current object क क member क point क This keyword क constructors क class PersonName { string name; public PersonName(string name) { this.name = name; } public void show() { System.out.println("Name is : "+name); } } class ThisDemo { PersonName pn = new PersonName("Vipin"); pn.show(); } क ऊ ए ए उ क this keyword PersonName class क name variable क औ constructor ए ए parameter क distinguish क क ए क this keyword क compiler क क क name क क name assign क क situation current object क member क point क उ क ए this keyword क क This keyword क एक argument क क क
  64. 64. Chapter 12 Constructors This chapter covers:  What are constructors?  Rules for creating constructors  Types of constructors Introduction to java constructors object क क क task perform क क variable क initialize क constructor create क Objects क क क क constructor क क उ क ए class क object create क उ क variables क values values user object create क input क Object ए क user values(arguments) pass क क values क class क variables क assign क क constructor क through क constructor उ values क assign क object create क क क क क उ क values क constructor क constructor क execute क object user क ए ready क constructor ए क java automatically constructor ए क Constructors java क memory allocation process क part Constructor क क characteristics constructors ए क क rules क क
  65. 65.  Constructor एक method क  Constructor क class क  Constructor क क return type Types of java constructors Java 4 क constructors क Default constructor क constructor create क java automatically default constructor call क constructor variables क उ क values क according memory allocate क Normal constructor constructor create क औ क body class variables क compile time initialize क क उ class Person { String Name; int age; Person() //Constructor { Name = "Vipin" age = 24; }
  66. 66. public void display() { System.out.println("Name is : "+Name+" Age is : "+age); } } class NorCon { public static void main (String args[]) { Person p1 = new Person(); p1.display(); } } Parameterized Constructors Constructors parameters pass क क Objects ए क variables क value arguments क pass क क values constructor variables क assign क क क उ class Person { String Name; int age; Person(String n , int a )
  67. 67. { Name = n ; age = a ; } public void display() { System.out.println("Name is : "+Name+" Age is : "+age); } } class ParaCon { public static void main (String args[]) { Person p1 = new Person("Vipin",24 ); p1.display(); } } Copy constructor Copy constructor क क object क copy क क ए क एक object क value object copy क objects same values क point क Copy constructors class क object create क उ class क object argument क pass क class Person {
  68. 68. int age; Person(String n , int a ) { Name = n ; age = a ; } Person(Person p ) // Copy Constructor for p2 object { Name = p.Name; age = p.age; } public void display() { System.out.println("Name is : "+Name+" Age is : "+age); } } class CopyCon public static void main (String args[]) { Person p1 = new Person("Vipin",age); Person p2 = new Person(p1); p1.display(); p2.display(); } }
  69. 69. Chapter 13 Methods This chapter covers:  What are methods?  Structure of method definition  Structure of method call Introduction to java methods क क क एक क क एक task क program क perform क क क methods क क क एक code क क एक method operation क perform क क क एक code क task perform क , उ उ method क call क क Method basically एक block of statements block एक particular operation perform क operation क program perform क method क क उ call क औ compiler उ method क execute क Java methods क उ println() method क क क program क method क क क ?? method java library define क method क क क क क string क क उ क screen print क क method variables क pass क क उ क values print
  70. 70. क क क method क क call क औ string variables क औ method उ execute java library method क definition ए क उ code program क औ उ code क क क hello world program 10 line क Methods program code क reduce क औ computer क memory क methods क programmers क same code programmers क time Structure of method definition access_specifier return_type method_name (parameters list) { // statements to be executed } access specifier Access specifier show क क method क क क private, public protected return type Method क execution क method result क क क value return क define क क method क value return क void method name method क program unique ए parameters list variables values method क call क pass क
  71. 71. Method operation perform क औ result return क execution क ए क उ क क addition क method उ 2 numbers pass क क क क add क क method क result return क values औ variables क comma separate क Structure of method call If in the same class If in another class methodName(arg1,arg2….); objectName.methodName(arg1,arg2); Example class PersonsInfo { public void Separator()// our method which separates information of persons { System.out.println("--------------------------------------------------------------------------- --"); } public static void main(String args[])
  72. 72. { System.out.println("Name : Sita Age : 23"); Separator(); System.out.println("Name : Ram Age:24"); Separator(); System.out.println("Name : Radha Age : 23"); Separator(); System.out.println("Name : Krishn Age:24"); } } Method overloading software's develop क क क program एक क क क methods methods क औ उ क क क क data क add क उ क ए methods ए उ methods क क क ए क उ क memorize क क program क क क क software develop क methods क क क situation method overloading क क Method overloading methods एक task perform क उ क एक क addition क methods addition क क क integer क add क क double क add क क एक क क एक compiler क क क क method call क
  73. 73. methods क same क methods parameter types औ उ क compiler run time क क method execute क method arguments match method execute Example public class overDemo { public static int sum(int a, int b) { return a+b; } public static int sum(double x, double y) { return x+y; } public static void main(String args []) { System.out.println(sum(3,5)); System.out.println(sum(3.5,5.3)); } }
  74. 74. ऊ ए ए example 2 sum methods एक sum() method integers क add क औ double values क add क Method call क sum() method integers pass क integers sum() method execute औ double values pass क double sum() method execute Method overriding क class क inherit क उ क methods क access क क क क method क definition क sub class क according उ method क change क super class क क method क sub class define क क उ method क edit क क क sub class क ए work क क method overriding क Method overriding sub class super class method क औ उ method क edit क क क क क super class क method क override क उ क ए एक class Area औ उ display() method class क Circle class inherit क Circle class Area class क display method क क क उ method क Circle class क क क edit क क क Area class क एक rectangle class inherit क display() method क क क क क define क क क method क override क क 2 ए  Super class क method क औ sub class क method क same  Sub class क parameter list super class क parameter list match ए
  75. 75. Example class Area { public void display() { System.out.println(“Displaying area……..”); } } class circle extends Area { public void display() { System.out.println(“Displaying circle…….”); } public static void main(String args[]) { Area obj = new Area(); obj.display(); this.display(); } }
  76. 76. Chapter 14 Inheritance This chapter covers:  What is inheritance  Types of inheritance  Inheriting a class  Example Introduction to java inheritance क क क औ उ क उ क एक class क (super class) क , औ class क (sub class) क क एक class class क properties (methods, variables ) क access क क क (sub class) क (super class) क property(methods, variables ) क access क क क क क क class औ class क methods क क class क क methods क क class उ methods क access क क क क ए class methods क access क उ class क sub class Sub class क ए क class क उ class क extend क inheritance क Inheritance एक code क क उ Inheritance क क re- usability क एक code क reuse क क
  77. 77. क एक class class क inherit क extends keyword क औ क क क class क क class inherit क क ए class क final keyword classes क final keyword उ inherit क क क class एक class क extend क क क class एक क classes क extend क multiple inheritance क औ क क multiple inheritance allow क multilevel inheritance implement क क class क inherit क super class क औ class inherit क sub class क एक क sub class super class क methods औ variables क access क क methods public औ protected declare क ए उ sub class access क क Super class क क private member क sub class access क क super class क औ class क extend क उ class क public औ protected members क क class क क Types of java inheritance Java 3 inheritance क क क application क ए क suitable क क क क क Single Inheritance Single inheritance एक class क क extend क क क inheritance क उ basic programming क
  78. 78. Multilevel inheritance Multilevel inheritance एक class class क extend क औ class class क extend क Hierarchical inheritance Hierarchical inheritance एक class क classes extend क inheritance क क super class क task क क sub task Inheriting a class क class क inherit क extends क उ क class क क extends keyword औ उ क class क inherit क उ class क Inheritance क उ
  79. 79. class A { public void display() { System.out.println("This is A class"); } public static void main(String args[]) { display(); } } class B extends A { public static void main(String args[]) { display(); } }
  80. 80. Chapter 15 Exception Handling This chapter covers:  What are excetions  Keywords (try, throw, catch)  Steps to handle exceptions  Some common exceptions  Example Introduction to java exception handling Exceptions run time errors Exception एक situation क ए program क क क memory क program क execute क ए ए, उ memory क computer क program क execution क out of memory exception situations क exceptions क क program क statement क semicolon , क program error क औ compile उ क exception generate क program क execute क क program exception क execute क ए क exceptions क handle क exception handling क exceptions क handle क क program exception क क exception code क skip क क क क code क execute क
  81. 81. Keywords Java क keywords क exceptions क handle क keywords क एक structure implement क keywords क Keywords Explanation Try क program क code exception generate क क , उ try block उ क ए program क mathematical operation क औ क क exception generate क उ code क try block catch try block क exception generate , block handle क block code exception execute क उ क ए एक message print क क क क exception generate throw exceptions क ए java library define औ exception java automatically throw क क क exceptions create क क ए क क क throw क क ए throw keyword क predefined exception throw क क Throws nested try blocks क क क क exception क outer try block handle क situation throws keyword क method definition क throws keyword क exceptions क क क exception outer try block उ handle क Finally Exception handle क क code execute क उ finally block Try block exception क compiler उ code क execute क
  82. 82. औ catch block क finally block क execute क Steps to handle exceptions 1. उ code क try block exception generate क 2. Try block क catch block exception क handle क क ए code ए क exception related क message print क क 3. Exception handle क क code execute क उ finally block Some common exceptions Exceptions क handle क exceptions क क ए क exceptions java regularly common exceptions practice क क औ skill क improve क क Java regularly क common exceptions क Arithmetic Exceptions क arithmetic error क क number क zero divide क क क क क variable उ क size value store क क क क Arithmetic-Exception generate Class Cast Exception क class क reference class store क औ class class क sub class Class-Cast-Exception generate
  83. 83. Array Store Exception string array औ उ string store क क क क Array-Store- Exception generate Array Index Out Of Bounds Exception क array क size 10 औ 11th position value store क क क क 11th position क access क क क क Array-Index-Out-Of-Bounds-Exception generate Illegal Argument Exception क method invalid argument pass क क int क string क Illegal- Argument-Exception generate Null Pointer Exception Java क reference variable क null value assign क क क reference variable क क क क NullPointerException generate Number Format Exception क string value क number cast क क क क Number-Format-Exception Example Import java.lang.*; class { public static void main(String args[])
  84. 84. { int num = 120; int a = 0; try { num = num / a; System.out.println(num); } catch(ArithmeticException e) { System.out.println(“You can not divide a number by zero”); } } }
  85. 85. Chapter 16 Interfaces & Packages This chapter covers:  What are interfaces?  Example  What are packages?  Creating packages  Using packages  Some common packages Introduction to java interfaces Java interfaces क concept एक उ क क क एक औ क क एक क एक क क क क ए क क क क sales department, production department, accounts औ management department क setup क क क क क क क क depend क interfaces classes क क उ क Class क क क उ class depend क Java interface उ क exam time topics क headings क क औ ए उ headings क detail क Interface क boss क औ class क employee क interface क क औ class उ क क क Interface क क क Interface define क ए methods क क क task क ए interface क
  86. 86. Interfaces define क ए methods by default abstract क क body Interface क public declare क क class interface क implement क उ implement declare क ए methods क definition provide क क method क क एक interface क क class extend क Interfaces implement क क ए implements keyword क Java multiple inheritance allow क java interfaces क multiple inheritance implement क क Interfaces super class क methods provide क , उ क definitions implement क class Interfaces classes क , क क object create क क औ क method क body declare क क Methods क interfaces variables declare क क Interfaces declare क variables static औ final ए एक interface एक interfaces क extend क क एक interface declare क क क classes उ interface क implement क क औ एक class उ interface implement क क क ए क interfaces क क (,) separate क Interfaces classes क Is-a relationship establish क उ क ए क pass एक interface fruits color औ taste methods औ एक mango क class mango class fruit interface क implement क Is-a relation क क क Mango is a fruit. Working with interfaces Interfaces क declare क क क ए interface keyword क public access modifier define क , क interface keyword क interface क क curly brackets उ methods क declare क क class implement क interfaces क methods by default public क
  87. 87. public access modifier methods क add क क क उ Structure Example public interface interface_Name { // methods without body; } public interface yrFriend { public void sales(); public void production(); public void accounts(); public void management(); } क क implements keyword क क ए क class interface क implement क क Interfaces क complete उ Example public interface yourFriend { public void sales(); public void production(); public void accounts(); public void management(); }
  88. 88. public class You implements yourFriend { public void sales() { // implement sales department } public void production() { // implement production department } public void accounts() { // implement production department } public void management() { // implement production department } }
  89. 89. Introduction to java packages java library ए क उ classes क उ क category क according packages organize क उ classes क क क packages क import क क ??. Classes क directly access क क Packages related types (classes, Interfaces etc.) क group क एक package क package क क क क क eCommerce software क क क source code क lines lines क एक programmer lines क software क ??. क क उ क ए क एक software क programmer क क क क programmers क code एक execute क possibility क क 2 programmers class interface क same situation program error show क problem क ए java एक mechanism provide क package क programmer code एक package क क programmers classes interfaces क same क program error Packages क क क ए क क क क क एक class method औ variable create क औ क class क program क error उ क packages क same classes क error generate क
  90. 90. Features of packages  Packages क java classes औ interfaces क maintain क क Packages क category क classes क packages maintain क क क programmer क productivity ढ़  Java packages क classes औ interfaces क access protection provide क package class create क क access modifier क उ class क packages क classes access क क क उ class package private modifier apply  Java packages duplicate names क problem solve Creating java packages Package create क क ए package keyword क keyword क package क unique package myPackage; क file क line ए क classes औ interfaces create क उ package include ए क classes क एक package add क files क एक file क क क क files top statement classes उ package include ए
  91. 91. Using java packages क programmer क package क क class क क उ क package import क import myPackage; Package क import क क classes क क क क क programmer क package क import क क औ उ क classes क क क क (.) operator क क class क directly access क क package member access क situation उ class क access क import newPackage.myClass Some common java packages Java एक main package Java API package क package क क क ए packages program import क क क क IO package औ AWT package क common औ क packages क क क क
  92. 92. java.language package language support classes classes java compiler क ए classes important java.util package language utility classes provide क क vector, hashtable java.io pacakge input ouput support classes provide क data क input औ output क ए facility provide क java.AWT package graphical user interface implement क क ए classes java.net package networking क ए classes provide क server connection establish क क ए classes java.applet package applets create क औ implement क क ए classes provide क Sub packages क package क एक औ package create क package sub package क क classes क categories क क क sub packages क packages क categories क क
  93. 93. Chapter 17 Multithreading This chapter covers:  What is multithreading?  Thread class  Runnable interface  Synchronization Introduction to java multi-threading phone क ए क औ TV क क क एक क क क क multitasking क java क क एक क क complete क क Java क feature क multi-threading क उ क ए क user input क ए wait क क क complete क क database connectivity क क क file क upload क क एक multi-threading क 2 2 क parts parts एक execute क क part thread क thread एक unique task complete क क ए responsible threads main thread क program क main main() method क thread क एक life cycle life cycle thread क stages thread क object ए क , एक thread new state क thread object start() क क thread runnable state क run()
  94. 94. method क thread running state क thread क execution क ए wait क thread waiting state औ thread क execution complete thread destroyed stage Java multi-threading 2 implement क क क thread क extend क क Runnable interface क implement क क run() क methods program क thread क extend क क औ run() override क Runnable interface implement क क Thread class implementation Thread class methods provide क क thread class क implement क क ए क methods क override क क क run() override क क Thread class क क important methods ए Method Description getName() Returns name of thread. getPriority() Returns priority of thread. isAlive() Returns true if thread is active. join() Joins two threads. run() Threads task is defined in this method. sleep() Make a sleep for give time in milliseconds. start() Starts a thread. क thread class क extend क क run method क override क औ methods क override क क क run() method क override क necessary क class क object create क Object create क thread क एक unique क क
  95. 95. Object create क क उ object start() method क क start() automatically run() method क call क , औ क thread क execution start threads create क उ object create क class JavaHindi extends thread { public static void main(String args[]) { JavaHindi jh = new JavaHindi(); jh.start(); } Public void run() { System.out.println(“Thread is running at www.besthinditutorials.com”); } } Runnable interface implementation Runnable interface एक method run() method क definition क class provide क एक class create क , run() क implement क क Thread class क object ए क thread क object Runnable
  96. 96. interface क implement क class क object औ thread क क औ उ क thread class क object start() method क call क Runnable interface क implement क क object thread क object pass क thread क object उ class क object क point क क उ class JavaHindi implements Runnable { JavaHindi() { Thread t = new Thread(this,HindiThread); t.start(); } Public void run() { System.out.println(“Thread is running at www.besthinditutorials.com”); } public static void main(String args[]) { JavaHindi jh = new JavaHindi(); } }
  97. 97. Synchronization 2 2 क thread क एक resource (method) access , conflict conflict क ए एक technique क technique एक एक thread resource access क क technique क synchronization क Synchronization क technique क method क synchronized क ए उ क definition synchronized method add क क synchronized void myMethod(){}. Synchronization क concept क क ए क monitor क concept object क उ क monitor क thread synchronized क call क , monitor enter thread monitor enter उ resource lock क thread resource क free क क क thread resource क access क क क resource क synchronized क 2 क एक क क method क synchronized keyword क औ उ synchronized क क एक synchronized block create क औ block उ class क methods क क क , क synchronized क उ Synchronized(s1) // s1 is the object of class of which methods you are going to call { // call here methods that you want to make synchronized }
  98. 98. Chapter 18 File I/O This chapter covers:  What are streams?  Byte streams  Character streams Introduction to java file I/O program input क program run क क console क क औ output console क software data क एक execute क क input क human क क क Input क क output क क क क human क computer क screen possible क क output क क क औ execution क print क situation java क File I/O क mechanism क क क Java क classes provide क क input क file read क क औ output क file store क क input console क क file read क क औ output console क ए क file store क क क Files क input औ output operations perform क क ए stream क क Data क sequence क stream क Input stream input औ output stream output
  99. 99. Java streams 2 क Byte stream data bytes क form औ character stream data character क form क streams क Byte stream Byte stream data bytes क form input औ output क ए 2 classes provide क abstract classes classes methods provide क क files क operations perform क classes क InputStream एक abstract class byte input stream class FileInputStream class extend क औ क methods क file operations क ए क Method Description int read() Reads data from file in form of bytes. void close() Closes input stream FileInputStream एक byte stream input class class क object create क क byte input stream create क object different methods call क क files क operations perform क import java.io.*; public class FileIOExample { public static void main(String args[]) throws IOException
  100. 100. { FileInputStream in = new FileInputStream("directory-address-of-file"); int a; while((a = in.read()) != -1) { System.out.println((char)a); in.close(); } } } OutputStream एक abstract class एक byte output stream class FileOutputStream class extend क class क क methods ए ए FileOutputStream class क Method Description int write() Writes data to file in form of bytes. void close() Closes output stream FileOutputStream class एक byte stream output class class क object ए क औ उ object write method call क क bytes() क file write() क import java.io.*;
  101. 101. public class FileIOExample { public static void main(String args[]) throws IOException { FileOutputStream out = new FileOutputStream("directory-address-to-store-file"); a = 5; out.write(a); out.close(); } } Character Stream Character stream data bytes क characters क form Character stream input औ ouput क ए 2 abstract classes क classes क Reader Reader एक abstract class एक character input stream class FileReader class extend क class क methods ए Method Description
  102. 102. int read() Reads data from file in form of characters. void close() Closes output stream FileReader एक character input stream class Reader class क extend क class क object create क क character input stream create क उ object read method call क क data read क import java.io.*; public class FileIOExample { FileReader in = new FileReader("director-address-of-file"); int a; while((a=in.read())!=-1) { System.out.print((char)a); in.close(); } }
  103. 103. Writer एक abstract class एक character output stream class FileWriter class extend क class क क methods FileWriter class क Method Description int read() Writes data to file in character form. void close() Closes output stream FileWriter class क object create क क character output stream ए क उ object write() method call क क data write() क import java.io.*; public class FileIOExample { public static void main(String args[]) throws IOException { FileWriter out = new FileWriter("directory-addres-of-File"); int a = 5; out.write(); out.close(); } }
  104. 104. Chapter 19 Serialization This chapter covers:  What is serialization?  Serializable interface Introduction to java serialization क video game औ उ क क क क ए औ video game क क औ video game start क game क game start क क क क game क क क program क processing क उ क क Java क feature क Serialization क Serialization object क state क save क क क music player क उ pause औ play क feature add क song क pause क क play क औ song क क music player क ए situation serialization क क क क object क state क save क process serialization क औ उ object क restore क process de-serialization क Object क state byte stream क क file store क
  105. 105. क object क serialize क क object क serialize क उ क data members क value file store क क variable EmployeeName औ क employee क store क variable उ क file store object क De-serialize क value memory load Serializable interface क object क serialize क क ए क serializable interface implement क class serializable interface क उ क objects serialize क क class ClassToSerialize implements Serializable { String Name = "YourName"; int Age = 24; } Serializing objects क object क serialize क एक file ए औ object क current state उ file store क object क serialize क क ए ObjectOutputStream class क object create क class क object create उ FileOutputStream class क object argument क pass क क ObjectOutputStream class क object writeObject()
  106. 106. method call क object serialize क उ method argument क pass क ऊ ए उ क क एक class serializable interface क implement क क क class क objects क क serialize क क उ import java.io.*; public class HowToSerialize { public static void main(String args[]) throws IOException { FileOutputStream fstream = new FileOutputStream("directory-address-of-file); ObjectOuputStream obstream = new ObjectOutputStream(fstream); ClassToSerialize CTS = new ClassToSerialize(); obstream.writeObject(CTS); } }
  107. 107. De-serializing objects क object क processing क उ क state file memory load क क object क file memory load क क ए ObjectInputStream class क object create क Object create क FileInputStream class क object argument क pass क क ObjectInputStream class क object readObject() method call क method क उ class क object return क ए क उ class क reference variable cast क क store क import java.io.*; public class HowToSerialize { public static void main(String args[]) throws IOException, ClassNotFoundException { FileInputStream fstream = new FileInputStream("directory-address-of-file"); ObjectInputStream obstream = new ObjectInputStream(fstream); ClassToSerialize CTS2 = (ClassToSerialize) obstream.readObject(); System.out.println(CTS2.Name); System.out.println(CTS2.Age); } }
  108. 108. Chapter 20 Collections Framework This chapter covers:  What are collections?  Other interfaces Introduction to collections framework data structures ढ़ java collections क Java objects क एक organize क क ए क data structures (set, list, queue and array) क data structures क java collections क data structure क collection क collection framework क collections क objects क operations ( searching, sorting, insertion, deletion ) perform क क normal data क क Collections framework क क क क ए classes औ interfaces provide क ए classes interfaces क implement क classes क extend क क objects क organize क क क data structure ए क क Collections framework क interfaces औ classes generic , ए object क type collection ए क interfaces औ classes क
  109. 109. Collection interface Collections framework क interfaces collection interface क by default implement क Collection interface methods provide क objects क manage क क ए क methods क list Methods Description Boolean add(E obj) method क collection object add क Void clear() method call collection क objects क remove क Boolean contains(Object obj) method क collection object search क क object method true return क Boolean equals(Object obj) method calling collection क object pass क ए object क compare क औ equal true return क Boolean isEmpty() call क collection empty method true return क List interface ArrayList औ LinkedList classes list interface क implement क classes objects क list क store क एक list collection duplicate objects store क क classes क object create क क objects क list क store क क
  110. 110. ArrayList ArrayList<objType> ArrList = new ArrayList<objType>(); arrList.add(obj1); arrList.add(obj2); arrList.add(obj3); LinkedList LinkedList<objType> linklist = new LinkedList<objType>(); linklist.add(obj1); linklist.add(obj2); linklist.add(obj3); Set interface HashSet or TreeSet classes set interface क implement क Set collection objects क set क store क duplicate objects store क क क class क object create क क set collection ए क क
  111. 111. HashSet HashSet<objType> hSet = new HashSet<objType>(); hSet.add(obj1); hSet.add(obj2); TreeSet TreeSet<objType> tSet = new TreeSet<objType>(); tSet.add(); tSet.add(); Queue interface Queue interface क PriorityQueue class implement क collection objects store क First In First Out क form store PriorityQueue PriorityQueue<objType> pQueue = new PriorityQueue<objType>(); pQueue.add(obj1);
  112. 112. pQueue.add(obj2); Map interface HashMap औ TreeMap class Map interface क implement क Map collection data key औ value क pair store क element क store औ access क क ए key क Map collection elements unique HashMap HashMap<objType> hMap = new HashMap<objType>(); hMap.add(key,obj1); hMap.add(key.obj2); TreeMap TreeMap<objType> tMap = new TreeMap<objType>(); tMap.add(key,obj1); tMap.add(key,obj2);
  113. 113. Iterator interface Collection interface क interface Iterator interface क by default implement क interface iterator(), hasNext() औ next() methods provide क methods क collection क traverse क क collection iterator() method call क method collection क first element क index return क क iterator interface क reference variable store क क hasNext() method क क ए loop औ next() method क collection क values क traverse क ArrayList<objType> aList = new ArrayList<objType>(); aList.add(key,obj1); aList.add(key,obj2); Iterator<objType> itr = aList.iterator(); while(itr.hasNext()) { System.out.println(itr.next()); }
  114. 114. Chapter 21 Lambda Expressions This chapter covers:  What is functional interface?  What is lambda expression? Functional interface Lambda expressions क क functional interface क एक functional interface interface , क एक abstract method क multi- threading क ए क runnable interface एक functional interface क interface क क उ define क एक method define क उ क ए एक interface ए क एक function interface interface क welcome interface एक hello() क by default abstract method एक argument औ message print क interface Welcome { String hello(String name); }
  115. 115. Lambda expressions Lambda expression एक क method method क क type क body एक single statement क क curly braces औ return statement क method execute Lambda expression functional interface क abstract method क signature क Lambda expressions क क क क , type क available क variable initialization, return statement औ method argument औ conditions type क available lambda expression क क Lambda expression create क क ए lambda operator (->) क एक simple operator , क left side parameters औ right side method body lambda body क Lambda expression क result उ interface क reference variable store क क signature क उ class क reference variable ए क क functional interface क implement क Lambda expression क उ Welcome wel; String name = "Vipin"; wel = (name)-> { System.out.println("Hello"+name); };
  116. 116. Chapter 22 Generics This chapter covers:  What are generics?  Example Introduction to java generics क क addition क method क क क data type क variables क add क क data type integers add क औ उ method double add क क possible ??. क possible method क औ क क Generics क method क क data type क execute क क methods data type क parameters क pass क compiler क क क क data type क method क execute क Java क feature readability ढ़ , programmers क time औ computer क memory क क क data type क ए code क Generics क क reference types (class) क क क क primitive types क int औ char क generics क क क ए java primitive types क class क implement क क int क ए Integer औ double क Double
  117. 117. क methods classes, interfaces औ constructors क generic क Generic class क structure class GenWorld<T> { } क object ए क उ क structure क - GenWorld<Integer> obj1 = new GenWorld<Integer>(20); Example class GenWorld<T> { T getValue; public GenWorld(T n) { this.getValue=n; }
  118. 118. public void display() { System.out.println(this.getValue); } } public class GenDemo { public static void main(String args[]) { GenWorld<Integer> = intgen = new GenWorld<Integer>(10); GenWorld<String> Stringgen = new GenWorld<String>(“vipin”); intgen.display(); Stringgen.display(); } } ऊ ए उ क क class क declare क class क क (&lt; &gt;) brackets generic declare क क generic variable declaration क variable क type generic क ऊ ए क
  119. 119. क एक constructor क generic argument object create क क उ convert औ क क generic class क different क ए क क argument क क object ए क . क ऊ ए ए उ क Generic methods क ऊ ए ए example क एक generic class क method generic type क क क ए method generic क क class generic method declare क क generic Generic methods ए क क ए structure <T> void myMethod(T x) { T a = x; System.out.println("hello",a); }
  120. 120. Generic constructor Classes औ methods क constructors क generic declare क क क methods क generic declare क Constructor क generic क ए class क generic क क उ - class GenWorld { public <T>GenWorld(T arg) { // this is is a generic constructor } } Generic interfaces Classes, methods औ constructors क interfaces क generic declare क क क क क simple public interface myInterface<T> { public T myFunction(); }
  121. 121. public class myClass implements myInterface<T> { public T myFunction() { // } } Bounded types ऊ ए ए उ T क क data type replace क क क क क क क क numbers क क numbers क क data type pass क क situation क handle क क ए java bounded types provide क Type parameter(T) declare क type क उ क super class क extend क क T क उ super class क types क replace क क क structure class GenWorld<T extends Number> { // class T क numbers क क }
  122. 122. Wildcard arguments एक क generic क एक particular type argument क object ए क क object generic क एक particular type क ऊ ए ए उ क intgen एक generic type क integer argument क ए क ए intgen औ stringgen क object क उ क क object क refer क क क object integer type argument क create क क क क generic क object क print क उ क ए एक function object क argument क औ print क क ए क void dispObj(GenWorld<T> obj) // can not do this, because all object are not allowed with this statement and function checks for strings only. { // } क ऊ क क क क क क object pass क क wildcard arguments क क औ function क क क object क print क क Wildcard क structure औ उ ए void dispObj(GenWorld<?> obj) { }
  123. 123. Chapter 23 Event Hanlding This chapter covers:  Introduction to Event Handling  Different types of event classes  Examples Introduction to java event handling क GUI application क क mouse click क क menu क item select क क button press क events generate क क क user क action events generate User क action components क state change , compiler क क event generate events क क ए handle क क compiler क क mouse click क क औ button press क क event handling क class event generate उ source class क औ class event क handle क listener Event generate , क ए listener class क listener interface implement क Event handling उ क क क क क bell bell एक event generate क event क handle क औ क situation क source class , औ listener class औ (listener class ) bell Bell listener interface , implement क एक
  124. 124. क bell क क क क क listener interface implement क क क क क event generate events क ए क listener interfaces , क mouse related events क ए MouseListener औ keyboard related events क ए KeyListener Listener class क events क notification उ interface क implement क उ क ए Mouse events क Listener interface implement क क source class क define क क mouse related क event generate क class क क एक method क , क उ addMouseListener(MouseListener obj) // obj is object of listener class statement source class , source generate mouse related events क notification listener class क औ listener class उ events क handle क listener interface उ क events possible क उ क ए एक method methods क override क क event क handle क क क MouseListener interface 5 क mouse events क handle क क 5 method ए methods क क  public void mouseClicked()  public void mouseEntered()  public void mouseExited()  public void mousePressed()  public void mouseReleased()
  125. 125. एक उ क क क क , applets event based program उ applets क क AWT Swing library क events क क क Example // Source class public class ListenToMe extends Applet { public void init() { String msg; YesSpeak ys = new YesSpeak(); addMouseListener(MouseListener ys);//passing listener object } public void paint(Graphics g) { g.drawString( msg,30,30); } }
  126. 126. //Listener class class YesSpeak implements MouseListener { ListenToMe lm = new ListenToMe(); public void mouseClicked(MouseEvent me) { lm.msg = "Mouse was Clicked!!"; repaint(); } public void mouseEntered(MouseEvent me) { lm.msg = "Mouse was entered!!"; repaint(); } public void mouseExited(MouseEvent me) { lm.msg = "Mouse was exited!!"; repaint(); }
  127. 127. public void mousePressed(MouseEvent me) { lm.msg = "Mouse was pressed!!"; repaint(); } public void mouseReleased(MouseEvent me) { lm.msg = "Mouse was released!!"; repaint(); } } //HTML file <html> <head> <title>Event Handling</title> </head> <applet code="ListenToMe.java" width=300 height=300> </applet> </html>
  128. 128. Adapter classes क listener class क listener interface implement क , क उ interface क methods क implement क क उ क mouse listener class क interfaces क implement क क क क method क implement क क क एक method क implement क situation adapter classes क क क listener interface क ए एक adapter class provide क , क MouseListener interface क ए MouseAdapter औ KeyListener interface क ए KeyAdapter adapter class उ interface क methods क default implementation provide क क methods क implement क क method क उ override क Adapter classes क programmers क time क उ //source class public class AdapterCall extends Applet { String msg; public void init() { AdapterReply ar = new AdapterReply(); addMouseListener (ar); } public void paint(Graphics G) { g.drawString(msg,30,30); }
  129. 129. } //listener class class AdapterReply extends MouseAdapter { AdapterCall ac = new AdapterCall(); public void mouseClicked(MouseEvent me) { ac.msg = "mouse was clicked"; repaint(); } } //HTML file <html> <head> <title>adapter handling</title> </head> <applet code = "ÄdapterCall.java" width=300 height=300> </applet> </html>
  130. 130. Chapter 24 Applets This chapter covers:  What are applets?  Applets life cycle methods  Example Introduction to java applets Applet एक java program browser run एक HTML क क क क HTML code include क Java program क file औ HTML program क files HTML java program क load क क ए <applet> tag क क HTML क browser HTML क java program load क क ए क applet (java program) क औ HTML file क एक server save क Applet java program Applet class क extend क Applet program क .class extension save क क browser applet क applet क code उ user क machine download applet क code user क machine download applet browser ए क क क applets client side applications Applets क run क ए JVM क JVM browser plugin क क क system क
  131. 131. Applet क browser क एक applet viewer क क applet program क HTML include क क directly क , java automatically applet क applet viewer क एक applet java program main() Applet class क life cycle methods provide क applet क handle क method क एक specific task perform क क ए Applet क life cycle methods एक एक execute क methods क क क Life cycle of java applets Applet 5 important methods provide क , override क methods क life cycle methods क एक applet program life cycle methods क methods क applet program control provide क methods ए  init() - method variables क initialize क क क object ए क क क क initialization method क क क applet क background color set क क  start() - init() method क automatically call method browser applet क call क  stop() - applet क stop क क ए क applet HTML page क क क window method call औ applet pause उ window , applet
  132. 132.  destroy() - browser क close क call औ applet destroy  paint() - method क applet क draw क क ए क method start() क call applet क एक complete उ Example // Java code class picture extends Applet { public void init() { void setBackground(color.red); } public void paint(Graphics g) { g.drawString("Applet are for GUI",30,30); } } //HTML code
  133. 133. <html> <head> <title>applet example</applet> </head> <applet code="picture.class" width="300" height="300"> </applet> </html> Parameter passing in java applets java file क HTML file क through parameters क क क क input user क form क औ further processing क ए क input क java file क pass क क क ए applet API parameter passing क feature provide क Java file क parameters pass क क ए HTML एक <param> क tag provide क tag क <applet> starting औ </applet> closing tags क क 2 attributes attribute name attribute उ value क parameters क pass क attribute value name attribute pass क ए naam क value key value pair क work क Java file parameters क include क क ए एक variable ए क क variable क value provide क क ए एक getParameters() method क क method उ parameter क pass क , क value variable store क method उ parameter क value variable store क क उ
  134. 134. Applets java क advanced feature , क क क क graphics design क क //html file <html> <head> <title>applet example</applet> </head> <applet code="picture.class" width="300" height="300"> <param name=userName value=Vipin Sharma> </applet> </html> //java file class userName extends Applet { String username; public void start() { username = getParameter("userName"); } public void paint(Graphics g) { g.drawString(username,30,30); } }
  135. 135. Chapter 25 Abstract Windows Toolkit This chapter covers:  What is AWT?  Container classes  Component classes  Frame class Java AWT (Abstract Windows Toolkit) Java GUI (Graphical User Interface) create क क 2 क , AWT औ SWING. Swing AWT क extended version , क advanced features AWT क graphical application develop क क AWT एक GUI library , graphical application graphical components(Buttons, Text box, Check box) add क क ए packages औ classes provide क AWT library क क java program क क क उ क ए क java.awt.* package क import क क application क calculator text editor AWT library क components (Buttons, Text-box, Check-box etc.) क क ए क AWT क क क क components classes क represent क classes क object create क औ components क application add AWT क क क क Swing क क क क क problem
  136. 136. AWT library 2 क classes container औ component classes AWT library 2 क classes क 2 क classes क concept क AWT क क problem क classes क Container classes Container एक window components क add क क application क main window , क browser क window window component क ए base क क क window components(buttons, text boxes, check boxes ) क add क एक container क container क add क क AWT library 4 क container classes क क क औ उ components क add क क frame class क क container classes क Classes Explanation Window एक window window क border औ menu bar Panel एक window title bar औ menu bar औ window क border Frame एक window menu bar औ title bar औ window क borders Dialog क window क एक window क user event क message औ उ क action क ए components क display क windows क according customize क क क window क size according क औ window क layout क , define क क
  137. 137. क क ए AWT library क methods provide क methods क औ upyog Method Explanation Example add(Component obj) क क component container add क क क ए क component class क object क add(b1); setSize(height,width) method क container क size set क setSize(100,300); setLayout(LayoutManager obj) method क container layout define क setLayout(null); setVisible(true/false) method क container क visible औ non-visible क setVisible(true); Component classes Components controls , users interact क क button, text-field, scroll-bar औ text-area Components standalone container क component क क क component ए क औ उ container add क क user components क क क component एक class क represent क Component create क क ए simple उ component class क object ए क क common components औ उ क उ
  138. 138. Classes Explanation Button class क object create क क एक button create क क Check-Box class check-box ए क क ए क Choice class एक drop down menu ए क क Label class क object ए क क एक label ए क क List class एक list create क क Containers क components क configure क क क components क background color change क क ओ उ क size क क क क क ए AWT library methods provide क methods क components क application क according configure क क Method Explanation Example setBackground(color) component क background color change क क setBackground(red); resize(height,width) method component क size क क क क resize(30,80); move(int,int); method component क dynamically move क क move(50,120) setBounds(int,int,int,int) method component क starting position set क setBounds(30,150,200,160)
  139. 139. Frame class Frame एक container class application औ need क according क container क क क frame क क Frame container क title bar, menu bar औ borders ए basic graphical applications क ए क AWT क example frame class क क Frame class क 2 क क क frame class क extend क क frame class क extend क क frame class क object create क क उ क ए class guiLabel extends Frame { guiLabel() { Label lb = new Label("This is AwT BeSt ExAmPlE"); add(lb); setSize(200,200); setVisible(true); } public static void main(String args[]) {
  140. 140. guiLabel gl = new guiLabel(); } } ऊ ए ए उ frame class क extend क उ क क ए उ frame class क object क class guiButton { public static void main() { Frame f = new Frame(); Button b1 = new Button("Click it!!"); f.add(b1); f.setTitle("Button Example"); f.setSize(200,200); f.setVisible(true); } }
  141. 141. Chapter 26 Swing This chapter covers:  Introduction to Swing  Different Swing classes  Example Introduction to java swing Abstract windows toolkit क क क क क ए swing क AWT library basic GUI controls provide क Swing AWT क advanced version AWT क 2 problems  AWT programs size  AWT components fixed , उ change क क problems क swing remove क Swing AWT based ए swing AWT क replace क swing क familiar swing क क क
  142. 142. Features of java swing  swing क Platform independent  swing components lightweight  Swing plug-gable look and feel क support क  Swing MVC(Model-View-Controller) architecture क क Swing classes JWindow JWindow container hierarchy क represent क JFrame औ JDialog class क higher क JFrame JFrame class AWT क frame क एक container क window components add क क ए क क design क different components क buttons, labels add क क Components add क क ए add() क JDialog क ए क क ए क Dialog box क JComponent swing hierarchy components क represent क swing components क directly inherit क
  143. 143. JLabel क object ए क क text labels ए क add क क JButton क object ए क क window button क क क ए क एक string क क क JTextField क create क क ए क text box add क क JScrollBar class ए क scroll bar क क ए क JMenuBar क window menu bar add क क JCheckBox क ए क क window check box add क क JList क window एक list क JTextArea क ए क text area क क
  144. 144. JRadioButton application radio button add क क ए क Example public class swingDemo { public static void main(String args[]) { JFrame frame = new JFrame(); JButton button = new JButton("Click here!"); button.setBounds(100,100,100,60); frame.add(button); frame.setSize(300,300); f.setVisible(true); } }

×