Advanced Java
Total Page:16
File Type:pdf, Size:1020Kb
Advanced Java Sudhanshu Maurya, Published by - Jharkhand Rai University Subject: ADVANCED JAVA Credits: 4 SYLLABUS Overview Of Java Brief history of Java, Java and the web, Java architecture, Basics of a typical Java environment, Java applicationsvs. Java applets, Java Development Kit (JDK) Java and other High level Languages: Comparison of Java with other high level languages, Importance and limitations of Java. Object-oriented Programming Classes and objects, class variables and methods, writing classes, subclasses, files Object-Oriented concepts in Java: Classes in Java, Encapsulation, Polymorphism, Constructors, Garbage collection. Java Programming Design Java’s built-in data types, Java’s inner classes, Operators. Flow-Control Statements Conditional statements, Loop statements, Flow-breaking statements. Reusing Classes Composition syntax, Inheritance syntax, Combining Composition and inheritance, Protected, Incremental development, Initializing and class loading. Introduction to objects The progress of abstraction, Inheritance: reusing the interface, Interchangeable objects with polymorphism, Multithreading, Persistence. Exception Handling And Threading In Java Why use exception handling, Hierarchy of exception classes, Exception handling constructs, Methods available to exceptions, Creating own exception classes Threading: Creating and running a thread, Thread- control methods, Thread life cycle, Thread groups, Thread synchronization, Inter-thread communications, Priorities and scheduling, thread local variables, Daemon threads. Event Handling Ignoring the event, Handling the component in the originating component, Delegating the event Java’s Event Types: Adjustment events, Ancestor events, Component events, Container events, Focus events, Input method events, Internal frame events, Item events, Key events, menu events, Mouse events, Paint events, Pop-up menu events, Text events, Window events. Windows Toolkit Java abstract windowing toolkit, Networking, Modifiers, Packages and interfaces. Suggested Reading: Gosling, James, A brief history of the Green project. Java.net, no date Gosling, James, A brief history of the Green project. anonymous-insider.net, no date Gosling, James; Joy, Bill; Steele, Guy L., Jr.; Bracha, Gilad . Lindholm, Tim; Yellin, Frank Patrick Naughton: Java Was Strongly Influenced by Objective-C David Bank: The Java Saga. Patrick Naughton: The Long Strange Trip to Java is-research GmbH: List of programming languages for a Java Virtual Machine How Java's Floating-Point Hurts Everyone Everywhere ADV ANCED JA V A ADVANCED JAVA SEM-III COURSE OVERVIEW Accurate programming is the primary need of any Computer subject introduces the student to the concepts in the study of Science application. Software Engineering techniques provide Object oriented programming using classes, It familiarizes the one such means of estimating almost accurately the estimated students with the various methods for handling events time required for writing accurate codes and testing data. occurring from users use of keyboard keys and mouse Analysis of such a user data and his requirements present the movements. Also the student understands Exception Handling usefulness of the information. The techniques thus form the methods. basis of all engineering designs and is one singular most The students on completion of the course shall develop the important subject of study for all Computer Software Special- following skills and competencies: ists. It develops an understanding of the built-in errors of a. Basics of Java Programming. common nature. b. Use of Objects and classes. The aim of this subject is to develop students’ understanding c. Graphical user Interface. of the concepts of Java Programming. In particular the subject d. Event and Exception Handling.. is designed to develop the underpinning knowledge and skills e. File I/O handling. required to write complex programs and test procedures. This f. Database connectivity. i ADVANCED JAVA CONTENT ADV ANCED JA V A . Lesson No. Topic Page No. Lesson Plan ii Object Oriented Programming - Concepts Lesson 1 Overview of Java 1 Lesson 2 Basic of Java Programming 3 Lesson 3 Describing objects & classes 8 Lesson 4 Java Programming Constructs 16 Working with Java Programs Lesson 5 Examples and Excercises 23 Lesson 6 Working with Objects and Classes 25 Lesson 7 Conditionals and storing values 32 Lesson 8 Looping techniques 36 Advanced Applications in Java – Advanced Lesson 9 Creating Classes and Applications in Java 40 Lesson 10 More About Methods 46 Lesson 11 Working with Applets 55 Using advanced Graphical interface Lesson 12 Graphics and Fonts 62 Lesson 13 Using Fonts and Color Objects 68 Lesson 14 Simple Animation and Threads 72 Lesson 15 Reducing Animation Screen Flickers 76 Lesson 16 More Animation, Images, and Sound 82 Lesson 17 Retrieving and Using Sounds 90 Lesson 18 Creating Animation 93 Throwing Exceptions in Java Lesson 19 Catching Exceptions 98 iii ADV ANCED JA ADVANCED JAVA V A CONTENT . Lesson No. Topic Page No. Threading in Java Lesson 20 Multithreading 104 Events Management Lesson 21 Interpreting Events and performing actions 111 Lesson 22 Handling UI Actions and Events 120 Windows Toolkit Lesson 23 The Java Abstract Windowing Toolkit 129 Lesson 24 Networking 136 Lesson 25 Using AWT Windows in Stand-Alone Applications 140 Lesson 26 Modifiers 146 Lesson 27 Packages and Interfaces 152 Reading And Writing Files Lesson 28 Streaming - Input 159 Lesson 29 Streaming - Output 166 Database Connectivity Lesson 30 Maintaining Safety 172 Lesson 31 JDBC – Examples & Exercises 176 Database Connectivity Lesson 32 Built in Optimizations 180 Lesson 33 The Java Virtual Machine 186 Lesson 34 The Garbage Collector 192 Lesson 35 The Java Class Hierarchy 200 L* = Lecture Hours (1.5 hours per lecture) iv UNIT-I LESSON-1 CHAPTER-1 OVERVIEW OF JAVA OBJECT ORIENTED PROGRAMMING CONCEPTS Introduction you can install by downloading the file and clicking the file’s icon ADV . This version is the easiest to set up. The other version can be Before you can start writing Java programs, you need acquire downloaded as a series of smaller files that must be assembled ANCED JA and set up some kind of Java programming software. after all files have been received. Although several different products are available for the development of Java programs, including many terrific once To download the Kit from Sun, visit the World Wide Web page that make programming much easier, the starting place for the http:// java. Sun . com / j2se / 1.3 /. V A most new Java programmers is the Software Development Kit, Although Sun Microsystems has not announced plans to make a set of tools for writing, debugging , and running Java version 1.3 of the Kit available for other systems , other programs. All of the examples in this lesson use the Kit, and companies have created implementation of the Java language you are encouraged to look at all other Java programming tools and development software that supports Java details about as you go through the remaining lessons. The material will these implementations are provided in the “Products and make more sense to programmers using the Kit , and it builds APLs” section of Sun “s official Java site, which is available at experience that will be beneficial no matter which http://java .sun.com . development software you use later on. If your system can run the Software Development Kit, Objective download it from Sun”s web site and save it your system in a The objective of this overview is to help you in downloading temporary folder. The file is more than 25 megabytes in size, so the software from the Sun Micro Systems for the kind of you “ll have time during the download to make coffee, knit a Operating System you are using. Here also you will learn the cardigan, or gnaw your foot off to escape any bear traps it might installation and testing procedure of Java. be caught in. Lesson in detail Workshop; installing the Kit The Software Development Kit is also referred to as the SDK. After the Software Development Kit has been downloaded to a Whenever Sun releases a new version of Java, the first tool that temporary folder ,you” re ready to install it . Sun’s own supports it is the Kit. installation documentation supplements the information To create all of the programs in this lesson , you must either provided during the hour, so be sure to consult it if you have use Software Development Kit 1.3 or another Java program- any questions about how the installation should be handled. ming tool that fully supports all of version 1.3 features . Window Installation There many different software packages that offer the capability Window version of the Kit can be installed in three steps; to create Java programs, but all of these are not created equally 1. Download the installation file from Sun , saving it in when language support is concerned . Some of these program- temporary folder on your system. ming tools only support Java 1.0 the initial version of the language , which was released by Sun Microsystems in late 2. Open the folder the contains the file. 1995. Other tools support Java 1.1, which was released in mid- 3. Double click the file’s icon and dialog box will open 1997. or version 1.2 from 1998. indicating that the Kit’s files are being unpacked and Can you tell , on which Operating systems installation will being. is Java available ? The Kit will be installed in a folder, with a name based on the version you ‘re downloading , such as \ jdk.3 Click the browse At the time of this writing , the Java Software Development button to select a different folder. Kit 1.3 was available directly from Sun Microsystems for the following systems; After choosing a folder , the Select Components dialog box will ask you to choose which components of the Kit to install. You • Microsoft Windows 95, 98 Me NT, and 2000 systems only need the Program files components accomplish the • Linux systems running on Intel Pentium machines with workshops and tutorial programs in this Course Pack , but you Linux kernel version 2.2.12 and glibc version 2.1.2 may also find the Demos useful if you can spare the hard disk • Solaris SPARC and solaris Intel systems space.