SlideShare a Scribd company logo
JAVA PROGRAMMING –
Packages - Stream based I/O
Dr R Jegadeesan Prof-CSE
Jyothishmathi Institute of Technology and Science,
Karimnagar
SYLLABUS
Packages- Defining a Package, CLASSPATH, Access protection, importing
packages. Interfaces- defining an interface, implementing interfaces,
Nested interfaces, applying interfaces, variables in interfaces and extending
interfaces.
Stream based I/O (java.io) – The Stream classes-Byte streams and
Character streams, Reading console Input and Writing Console Output, File
class, Reading and writing Files, Random access file operations, The
Console class, Serialization, Enumerations, auto boxing, generics.
UNIT 2 : PACKAGES, INTERFACES, STREAM BASED I/O
Topic Name : Introduction to Packages, Interfaces, Stream based I/O
Topic : Introduction to Packages, Interfaces, Stream Based I/O
Aim & Objective : To make the student understand the concepts of creation of
packages, interfaces and stream classes
Application With Example :Java programs to create and access the packages and
implementing interfaces. Java program to read and write data from and to streams.
Limitations If Any :
Reference Links :
• http://javabeginnerstutorial.com/core-java/
• Java The complete reference, 9th edition, Herbert Schildt, McGraw Hill Education
(India) Pvt. Ltd.
• https://www.tutorialride.com/core-java/packages-interfaces-in-java.htm
• Video Link details
• https://www.youtube.com/watch?v=iIwyrdc3Zvw
Universities & Important Questions :
• Define a package. What is the necessity of packages?
• What are the packages provided by Java API?
• Discuss about packages of java language
• What is a package? How do we design a package?
• What is package? Explain the procedure to create a package with the help of example
• How do you create a package? Explain about access protection in packages.
• What is the major difference between an interface and class?
• Compare and contrast between class and an interface.
• Define abstract class and interface and what the difference between them and
explain with Suitable examples
• How to design and implement an interface? Explain with example.
• What is multiple inheritance? Explain how it can be implemented in Java with the
help of an example
• Explain how interfaces can be implemented.
• Write an interface called Shape with necessary methods. Derived classes circle,
rectangle, triangle, cone, sphere and cube with appropriate constructors and
methods for area, volume also setting and displaying.
• Java does not support multiple inheritance. Then how is the problem solved explain
with suitable example.
▪ Packages
▪ Interfaces
▪ Stream based I/O
▪ Serialization
▪ Enumeration
▪ Generics
UNIT – II
CONTENTS
Interfaces
• In Java, only single inheritance is permitted. However, Java
provides a construct called an interface which can be
implemented by a class.
• Interfaces are similar to abstract classes (we will compare the
two soon).
• A class can implement any number of interfaces. In effect
using interfaces gives us the benefit of multiple inheritance
without many of it’s problems.
• Interfaces are compiled into bytecode just like classes.
• Interfaces cannot be instantiated.
• Can use interface as a data type for variables.
• Can also use an interface as the result of a cast operation.
• Interfaces can contain only abstract methods and constants.
Interfaces (cont)
• An interface is created with the following
syntax:
modifier interface interfaceID
{
//constants/method signatures
}
Syntax
public class Circle extends
GeometricObject implements
Comparable {
/* define class here make sure
to implement all the abstract
methods contained in the
interface(s)*/
}
Interfaces (cont)
• An interface can extend other interfaces with the following
syntax:
modifier interface interfaceID extends
comma-delimited-list-of-interfaces
{
//constants/method signatures
}
• Obviously, any class which implements a “sub-interface” will
have to implement each of the methods contained in it’s
“super-interfaces”
Interface Abstract class
Fields Only constants Constants and
variable data
Methods No implementation
allowed (no
abstract modifier
necessary)
Abstract or
concrete
Interface vs. abstract class
Interface vs. abstract class (cont)
Interface Abstract class
Inheritance A subclass can
implement many
interfaces
A subclass can
inherit only one
class
Can extend
numerous
interfaces
Can implement
numerous
interfaces
Cannot extend a
class
Extends one class
Interface vs. abstract class (cont)
Interface Abstract class
Root none Object (of all
classes)
names Adjective or
Nouns
Nouns
Comparable interface
• This interface imposes a total ordering on the
objects of each class that implements it. This
ordering is referred to as the class's natural
ordering, and the class's compareTo method is
referred to as its natural comparison method.
int compareTo (Object o)
Compares this object with the specified object for
order. Returns a negative integer, zero, or a
positive integer as this object is less than, equal to,
or greater than the specified object.
Thank you

More Related Content

DOCX
Class notes(week 7) on packages
PDF
Java packages
PPTX
Packages and Interfaces
PPTX
Packages and interfaces
PPT
Packages in java
PDF
Java programming -Object-Oriented Thinking- Inheritance
PDF
Java - Interfaces & Packages
PPTX
Unit3 part3-packages and interfaces
Class notes(week 7) on packages
Java packages
Packages and Interfaces
Packages and interfaces
Packages in java
Java programming -Object-Oriented Thinking- Inheritance
Java - Interfaces & Packages
Unit3 part3-packages and interfaces

What's hot (20)

PPTX
Pi j4.1 packages
PPTX
Introduction to java
PPS
Dacj 2-1 a
PPT
packages and interfaces
PDF
java-06inheritance
PPTX
java interface and packages
PPT
inheritance
PPTX
5.interface and packages
PPTX
Multiple inheritance possible in Java
PPT
Java inheritance
PPT
Java access modifiers
PPTX
Unit3 packages & interfaces
PPTX
Java package
PPTX
Inner classes in java
PPT
Packages in java
PPTX
Inheritance in JAVA PPT
PPT
Inheritance and Polymorphism
PPTX
Java Inheritance - sub class constructors - Method overriding
PPSX
Java Object Oriented Programming
PPTX
Packages
Pi j4.1 packages
Introduction to java
Dacj 2-1 a
packages and interfaces
java-06inheritance
java interface and packages
inheritance
5.interface and packages
Multiple inheritance possible in Java
Java inheritance
Java access modifiers
Unit3 packages & interfaces
Java package
Inner classes in java
Packages in java
Inheritance in JAVA PPT
Inheritance and Polymorphism
Java Inheritance - sub class constructors - Method overriding
Java Object Oriented Programming
Packages
Ad

Similar to JAVA PROGRAMMING – Packages - Stream based I/O (20)

PDF
Core_Java_Interview.pdf
PPTX
Java 6.pptx
PPT
Interface in java By Dheeraj Kumar Singh
PPTX
Interfaces in java
PPTX
Interface &packages
PDF
‏‏‏‏‏‏oop lecture 6_١٢٥٩٤٧taiz univercity.pdf
PDF
What is Interface in Java | How to implement Multiple Inheritance Using Inter...
PPTX
Unit II Inheritance ,Interface and Packages.pptx
PPTX
Module 4-packages and exceptions in java.pptx
PPTX
Inheritance.pptx
PPTX
Abstraction encapsulation inheritance polymorphism
PPTX
Suga java training_with_footer
DOCX
Core java questions
PDF
Top 371 java fa qs useful for freshers and experienced
PDF
Java Faqs useful for freshers and experienced
PPTX
Module--fundamentals and operators in java1.pptx
PDF
Abstraction in Java: Abstract class and Interfaces
PPTX
OBJECT ORIENTED PROGRAMMING Unit2 second half.pptx
PPT
Csci360 20 (1)
Core_Java_Interview.pdf
Java 6.pptx
Interface in java By Dheeraj Kumar Singh
Interfaces in java
Interface &packages
‏‏‏‏‏‏oop lecture 6_١٢٥٩٤٧taiz univercity.pdf
What is Interface in Java | How to implement Multiple Inheritance Using Inter...
Unit II Inheritance ,Interface and Packages.pptx
Module 4-packages and exceptions in java.pptx
Inheritance.pptx
Abstraction encapsulation inheritance polymorphism
Suga java training_with_footer
Core java questions
Top 371 java fa qs useful for freshers and experienced
Java Faqs useful for freshers and experienced
Module--fundamentals and operators in java1.pptx
Abstraction in Java: Abstract class and Interfaces
OBJECT ORIENTED PROGRAMMING Unit2 second half.pptx
Csci360 20 (1)
Ad

More from Jyothishmathi Institute of Technology and Science Karimnagar (20)

PDF
JAVA PROGRAMMING- GUI Programming with Swing - The Swing Buttons
PDF
JAVA PROGRAMMING - The Collections Framework
PDF
JAVA PROGRAMMING- Exception handling - Multithreading
PDF
Compiler Design- Machine Independent Optimizations
PDF
PDF
COMPILER DESIGN- Syntax Directed Translation
PDF
COMPILER DESIGN- Introduction & Lexical Analysis:
PPTX
CRYPTOGRAPHY AND NETWORK SECURITY- E-Mail Security
PDF
CRYPTOGRAPHY AND NETWORK SECURITY- Transport-level Security
PDF
CRYPTOGRAPHY & NETWORK SECURITY- Cryptographic Hash Functions
PDF
CRYPTOGRAPHY & NETWOK SECURITY- Symmetric key Ciphers
PDF
Computer Forensics Working with Windows and DOS Systems
JAVA PROGRAMMING- GUI Programming with Swing - The Swing Buttons
JAVA PROGRAMMING - The Collections Framework
JAVA PROGRAMMING- Exception handling - Multithreading
Compiler Design- Machine Independent Optimizations
COMPILER DESIGN- Syntax Directed Translation
COMPILER DESIGN- Introduction & Lexical Analysis:
CRYPTOGRAPHY AND NETWORK SECURITY- E-Mail Security
CRYPTOGRAPHY AND NETWORK SECURITY- Transport-level Security
CRYPTOGRAPHY & NETWORK SECURITY- Cryptographic Hash Functions
CRYPTOGRAPHY & NETWOK SECURITY- Symmetric key Ciphers
Computer Forensics Working with Windows and DOS Systems

Recently uploaded (20)

PDF
Machine learning based COVID-19 study performance prediction
PDF
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
PDF
Network Security Unit 5.pdf for BCA BBA.
PDF
NewMind AI Weekly Chronicles - August'25 Week I
PDF
Approach and Philosophy of On baking technology
DOCX
The AUB Centre for AI in Media Proposal.docx
PDF
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
PPT
Teaching material agriculture food technology
PPTX
Big Data Technologies - Introduction.pptx
PDF
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
PDF
KodekX | Application Modernization Development
PDF
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
PPTX
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
PPTX
Cloud computing and distributed systems.
PPTX
A Presentation on Artificial Intelligence
PPTX
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
PDF
Building Integrated photovoltaic BIPV_UPV.pdf
PDF
NewMind AI Monthly Chronicles - July 2025
PPTX
MYSQL Presentation for SQL database connectivity
PDF
Spectral efficient network and resource selection model in 5G networks
Machine learning based COVID-19 study performance prediction
Blue Purple Modern Animated Computer Science Presentation.pdf.pdf
Network Security Unit 5.pdf for BCA BBA.
NewMind AI Weekly Chronicles - August'25 Week I
Approach and Philosophy of On baking technology
The AUB Centre for AI in Media Proposal.docx
Build a system with the filesystem maintained by OSTree @ COSCUP 2025
Teaching material agriculture food technology
Big Data Technologies - Introduction.pptx
TokAI - TikTok AI Agent : The First AI Application That Analyzes 10,000+ Vira...
KodekX | Application Modernization Development
Peak of Data & AI Encore- AI for Metadata and Smarter Workflows
KOM of Painting work and Equipment Insulation REV00 update 25-dec.pptx
Cloud computing and distributed systems.
A Presentation on Artificial Intelligence
Effective Security Operations Center (SOC) A Modern, Strategic, and Threat-In...
Building Integrated photovoltaic BIPV_UPV.pdf
NewMind AI Monthly Chronicles - July 2025
MYSQL Presentation for SQL database connectivity
Spectral efficient network and resource selection model in 5G networks

JAVA PROGRAMMING – Packages - Stream based I/O

  • 1. JAVA PROGRAMMING – Packages - Stream based I/O Dr R Jegadeesan Prof-CSE Jyothishmathi Institute of Technology and Science, Karimnagar
  • 2. SYLLABUS Packages- Defining a Package, CLASSPATH, Access protection, importing packages. Interfaces- defining an interface, implementing interfaces, Nested interfaces, applying interfaces, variables in interfaces and extending interfaces. Stream based I/O (java.io) – The Stream classes-Byte streams and Character streams, Reading console Input and Writing Console Output, File class, Reading and writing Files, Random access file operations, The Console class, Serialization, Enumerations, auto boxing, generics.
  • 3. UNIT 2 : PACKAGES, INTERFACES, STREAM BASED I/O Topic Name : Introduction to Packages, Interfaces, Stream based I/O Topic : Introduction to Packages, Interfaces, Stream Based I/O Aim & Objective : To make the student understand the concepts of creation of packages, interfaces and stream classes Application With Example :Java programs to create and access the packages and implementing interfaces. Java program to read and write data from and to streams. Limitations If Any : Reference Links : • http://javabeginnerstutorial.com/core-java/ • Java The complete reference, 9th edition, Herbert Schildt, McGraw Hill Education (India) Pvt. Ltd. • https://www.tutorialride.com/core-java/packages-interfaces-in-java.htm • Video Link details • https://www.youtube.com/watch?v=iIwyrdc3Zvw
  • 4. Universities & Important Questions : • Define a package. What is the necessity of packages? • What are the packages provided by Java API? • Discuss about packages of java language • What is a package? How do we design a package? • What is package? Explain the procedure to create a package with the help of example • How do you create a package? Explain about access protection in packages. • What is the major difference between an interface and class? • Compare and contrast between class and an interface. • Define abstract class and interface and what the difference between them and explain with Suitable examples • How to design and implement an interface? Explain with example. • What is multiple inheritance? Explain how it can be implemented in Java with the help of an example • Explain how interfaces can be implemented. • Write an interface called Shape with necessary methods. Derived classes circle, rectangle, triangle, cone, sphere and cube with appropriate constructors and methods for area, volume also setting and displaying. • Java does not support multiple inheritance. Then how is the problem solved explain with suitable example.
  • 5. ▪ Packages ▪ Interfaces ▪ Stream based I/O ▪ Serialization ▪ Enumeration ▪ Generics UNIT – II CONTENTS
  • 6. Interfaces • In Java, only single inheritance is permitted. However, Java provides a construct called an interface which can be implemented by a class. • Interfaces are similar to abstract classes (we will compare the two soon). • A class can implement any number of interfaces. In effect using interfaces gives us the benefit of multiple inheritance without many of it’s problems. • Interfaces are compiled into bytecode just like classes. • Interfaces cannot be instantiated. • Can use interface as a data type for variables. • Can also use an interface as the result of a cast operation. • Interfaces can contain only abstract methods and constants.
  • 7. Interfaces (cont) • An interface is created with the following syntax: modifier interface interfaceID { //constants/method signatures }
  • 8. Syntax public class Circle extends GeometricObject implements Comparable { /* define class here make sure to implement all the abstract methods contained in the interface(s)*/ }
  • 9. Interfaces (cont) • An interface can extend other interfaces with the following syntax: modifier interface interfaceID extends comma-delimited-list-of-interfaces { //constants/method signatures } • Obviously, any class which implements a “sub-interface” will have to implement each of the methods contained in it’s “super-interfaces”
  • 10. Interface Abstract class Fields Only constants Constants and variable data Methods No implementation allowed (no abstract modifier necessary) Abstract or concrete Interface vs. abstract class
  • 11. Interface vs. abstract class (cont) Interface Abstract class Inheritance A subclass can implement many interfaces A subclass can inherit only one class Can extend numerous interfaces Can implement numerous interfaces Cannot extend a class Extends one class
  • 12. Interface vs. abstract class (cont) Interface Abstract class Root none Object (of all classes) names Adjective or Nouns Nouns
  • 13. Comparable interface • This interface imposes a total ordering on the objects of each class that implements it. This ordering is referred to as the class's natural ordering, and the class's compareTo method is referred to as its natural comparison method. int compareTo (Object o) Compares this object with the specified object for order. Returns a negative integer, zero, or a positive integer as this object is less than, equal to, or greater than the specified object.