Escolar Documentos
Profissional Documentos
Cultura Documentos
Presentation 1
Revision
1. Define Inheritance.
2. List the types of Inheritance allowed in java.
Objectives
At the end of this presentation, you will be able to Define package and its types List the advantages of packages
Reusability of Classes
Packages
Is a collection of classes that can be shared by Java programs.
Are classified into
in-built packages
user-defined packages.
Packages
Packages
In-built packages
Packages
In-built packages - system packages.
User-defined packages - Created by the
Advantages - Packages
Allows reusability across programs.
Allow classes to organize into units. Used to identify the classes. Same class name can be used in different packages.
Java Packages
The classes are grouped together based on their functionality.
Some of the important packages of Java are:
io
Cont
Structure of io Package
Package Class
Import all the classes of the package using *. Import single class using the class name.
import java.io.*;
Syntax
import java.packagename.*;
import java.io.BufferedReader;
Syntax
import java.packagename.classname;
Hands-On!
Program InputSample.java accepts input using input stream.
Activity 6.9.1
Step 1: Open InputSample1.java from Student data file.
Step 2: Type import java.io.*; in Code line 1. Step 3: Save and Compile the program. Step 4: Run and observe the output.
Summary
In this presentation, you learnt the following Package is a collection of classes that can be shared by Java programs.
Packages provides reusability, they allow classes to be organized into units. They are used to identify the classes. Packages enable classes to have same name across them.
Summary
In this presentation, you also learnt the following The classes are grouped together based on their functionality. Some of the important java packages are lang, util, io, awt, net and applet.
Assignment
Lab Exercise
1. Write a program to accept a string by importing the io package.