Introduction to Java Programming

Chapter 1 Introduction 1 1.1 JDK and IDE installation 1 1.1.1 Install JSE, aka jdk 1 1.1.2 Download IDE Eclipse 4 1.1.3 Creating and Running Java Programs 7 1.2 First Java Programs 8 1.2.1 What is Java Language? 8 1.2.2 Create and Run Welcome Program 10 1.2.3 Examples 10 1.3 Graphics 13 1.3.1 Chapter Exercises 17 1.3.a What did you learn? 18 Chapter 2 Data Types, Assignment, Output 19 2.1 Data Types and Identifiers 19 2.2 Expressions 21 2.3 Assignment Statement 24 2.4 Input from the Keyboard 26 2.5 Chapter Exercises 34 Chapter 3 Conditional Statements 37 3.1 Case for variables 37 3.2 If else Statement 40 3.3 Switch Case Statement 45 3.4 Comparison between if...else and switch...case statements 48 3.5 Chapter Exercises 49 iv Chapter 4 Repetition Statements 55 4.1 for Loop 55 4.2 while Loop 65 4.3 do-while Loop 69 4.4 Formatting Output Data 70 4.5 Reading from a Text File 72 4.6 Chapter Exercises 77 Chapter 5 Java Application Programming Interfaces (API) 85 5.1 Introduction 85 5.2 Math Class 86 5.3 String Class 90 5.4 Writing to a Text File 93 5.5 What did you learn? 95 5.6 Chapter Exercises 96 Chapter 6 Classes and Objects 99 6.1 Introduction 99 6.1.1 Importation of Class 100 6.1.2 Construction of an Object 100 6.1.3 Invocation of a Method 100 6.2 User-Defined Classes 101 6.2.1 User-Defined Methods 103 6.2.2 Scope Identifier 107 6.2.3 Accessing Visibility Modified Values 111 6.3 Accessors and Mutators 113 6.3.1 Class with the main() method 116 6.3.2 Overloaded Methods 118 6.4 Concept Understanding 132 6.4.1 Chapter Exercises 133 v Chapter 7 Arrays 135 7.1 Java Arrays 135 7.2 One-dimensional Arrays 136 7.2.1 Creation of Arrays 136 7.2.2 Visibility 140 7.2.3 Accessing Arrays and More 141 7.2.4 Reading Arrays 141 7.2.5 Writing into Arrays 144 7.3 Arrays as Parameters and Invoking Methods 146 7.4 Multidimensional Arrays 150 7.5 Exercises and Course Project 153 Chapter 8 Inheritances 161 8.1 Class Hierarchies 161 8.1.1 Composition Relationship (has-a) 162 8.2 Inheritance Relationship 164 8.3 Visibility and protected Modifier 178 8.4 Abstract Classes and Interfaces 181 8.5 Chapter Exercises 181 Chapter 9 Polymorphisms 185 9.1 Polymorphic References 185 9.2 Polymorphism via Inheritances 189 9.3 Polymorphism via Interfaces 196 9.4 Chapter Exercises 198 Chapter 10 Exceptions 201 10.1 Why Exceptions 201 10.2 Exception Class Hierarchies 205 10.3 Exception Handling 207 vi 10.4 Creating Exception Classes 210 10.5 Chapter Exercises 222 Chapter 11 Graphical User Interfaces 223 11.1 GUI Components and Class Hierarchies 223 11.2 Layout Managers 227 11.3 Event Handling 231 11.4 Revisit GUI Components 234 11.5 Chapter Exercises 241 Chapter 12 Introduction to Recursion and Graphics 245 12.1 Introduction 245 12.2 Recursion 246 12.2.1 Recursive requisites 248 12.2.2 Towers of Hanoi 250 12.3 Graphics 253 12.4 Chapter Exercises 261

Author: Dr. Nagaraj Rao

Learn more

Deals