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

What's hot (20)

PPTX
Pi j4.1 packages
mcollison
 
PPTX
Introduction to java
Kalai Selvi
 
PPS
Dacj 2-1 a
Niit Care
 
PPT
packages and interfaces
madhavi patil
 
PDF
java-06inheritance
Arjun Shanka
 
PPTX
java interface and packages
VINOTH R
 
PPT
inheritance
Mohit Patodia
 
PPTX
5.interface and packages
Deepak Sharma
 
PPTX
Multiple inheritance possible in Java
Kurapati Vishwak
 
PPT
Java inheritance
Arati Gadgil
 
PPT
Java access modifiers
Srinivas Reddy
 
PPTX
Unit3 packages & interfaces
Kalai Selvi
 
PPTX
Java package
CS_GDRCST
 
PPTX
Inner classes in java
PhD Research Scholar
 
PPT
Packages in java
Abhishek Khune
 
PPTX
Inheritance in JAVA PPT
Pooja Jaiswal
 
PPT
Inheritance and Polymorphism
BG Java EE Course
 
PPTX
Java Inheritance - sub class constructors - Method overriding
NithyaN19
 
PPSX
Java Object Oriented Programming
University of Potsdam
 
PPTX
Packages
Nuha Noor
 
Pi j4.1 packages
mcollison
 
Introduction to java
Kalai Selvi
 
Dacj 2-1 a
Niit Care
 
packages and interfaces
madhavi patil
 
java-06inheritance
Arjun Shanka
 
java interface and packages
VINOTH R
 
inheritance
Mohit Patodia
 
5.interface and packages
Deepak Sharma
 
Multiple inheritance possible in Java
Kurapati Vishwak
 
Java inheritance
Arati Gadgil
 
Java access modifiers
Srinivas Reddy
 
Unit3 packages & interfaces
Kalai Selvi
 
Java package
CS_GDRCST
 
Inner classes in java
PhD Research Scholar
 
Packages in java
Abhishek Khune
 
Inheritance in JAVA PPT
Pooja Jaiswal
 
Inheritance and Polymorphism
BG Java EE Course
 
Java Inheritance - sub class constructors - Method overriding
NithyaN19
 
Java Object Oriented Programming
University of Potsdam
 
Packages
Nuha Noor
 

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

PDF
Core_Java_Interview.pdf
ansariparveen06
 
PPTX
Java 6.pptx
usmanusman720379
 
PPT
Interface in java By Dheeraj Kumar Singh
dheeraj_cse
 
PPTX
Interfaces in java
Shiv Mehmi
 
PPTX
Interface &packages
Shah Ishtiyaq Mehfooze
 
PDF
‏‏‏‏‏‏oop lecture 6_١٢٥٩٤٧taiz univercity.pdf
nabeehmohammedtaher
 
PDF
What is Interface in Java | How to implement Multiple Inheritance Using Inter...
Edureka!
 
PPTX
Unit II Inheritance ,Interface and Packages.pptx
pranalisonawane8600
 
PPTX
Module 4-packages and exceptions in java.pptx
Radhika Venkatesh
 
PPTX
Inheritance.pptx
PRIYACHAURASIYA25
 
PPTX
Abstraction encapsulation inheritance polymorphism
PriyadharshiniG41
 
PPTX
Suga java training_with_footer
Sugavanam Natarajan
 
DOCX
Core java questions
Pradheep Ayyanar
 
PDF
Top 371 java fa qs useful for freshers and experienced
Gaurav Maheshwari
 
PDF
Java Faqs useful for freshers and experienced
yearninginjava
 
PPTX
Module--fundamentals and operators in java1.pptx
Radhika Venkatesh
 
PDF
Abstraction in Java: Abstract class and Interfaces
Jamsher bhanbhro
 
PPT
Csci360 20 (1)
manish katara
 
PPT
Csci360 20
neetukalra
 
Core_Java_Interview.pdf
ansariparveen06
 
Java 6.pptx
usmanusman720379
 
Interface in java By Dheeraj Kumar Singh
dheeraj_cse
 
Interfaces in java
Shiv Mehmi
 
Interface &packages
Shah Ishtiyaq Mehfooze
 
‏‏‏‏‏‏oop lecture 6_١٢٥٩٤٧taiz univercity.pdf
nabeehmohammedtaher
 
What is Interface in Java | How to implement Multiple Inheritance Using Inter...
Edureka!
 
Unit II Inheritance ,Interface and Packages.pptx
pranalisonawane8600
 
Module 4-packages and exceptions in java.pptx
Radhika Venkatesh
 
Inheritance.pptx
PRIYACHAURASIYA25
 
Abstraction encapsulation inheritance polymorphism
PriyadharshiniG41
 
Suga java training_with_footer
Sugavanam Natarajan
 
Core java questions
Pradheep Ayyanar
 
Top 371 java fa qs useful for freshers and experienced
Gaurav Maheshwari
 
Java Faqs useful for freshers and experienced
yearninginjava
 
Module--fundamentals and operators in java1.pptx
Radhika Venkatesh
 
Abstraction in Java: Abstract class and Interfaces
Jamsher bhanbhro
 
Csci360 20 (1)
manish katara
 
Csci360 20
neetukalra
 
Ad

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

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

Recently uploaded (20)

PPTX
𝙳𝚘𝚠𝚗𝚕𝚘𝚊𝚍—Wondershare Filmora Crack 14.0.7 + Key Download 2025
sebastian aliya
 
PDF
ArcGIS Utility Network Migration - The Hunter Water Story
Safe Software
 
PDF
FME as an Orchestration Tool with Principles From Data Gravity
Safe Software
 
PDF
“Scaling i.MX Applications Processors’ Native Edge AI with Discrete AI Accele...
Edge AI and Vision Alliance
 
PPTX
Enabling the Digital Artisan – keynote at ICOCI 2025
Alan Dix
 
PDF
UiPath Agentic AI ile Akıllı Otomasyonun Yeni Çağı
UiPathCommunity
 
PDF
The Future of Product Management in AI ERA.pdf
Alyona Owens
 
PPTX
01_Approach Cyber- DORA Incident Management.pptx
FinTech Belgium
 
PPTX
Simplifica la seguridad en la nube y la detección de amenazas con FortiCNAPP
Cristian Garcia G.
 
PDF
The Growing Value and Application of FME & GenAI
Safe Software
 
PDF
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Priyanka Aash
 
PDF
Automating the Geo-Referencing of Historic Aerial Photography in Flanders
Safe Software
 
PDF
Plugging AI into everything: Model Context Protocol Simplified.pdf
Abati Adewale
 
PDF
LLM Search Readiness Audit - Dentsu x SEO Square - June 2025.pdf
Nick Samuel
 
PPTX
Practical Applications of AI in Local Government
OnBoard
 
PPTX
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
pcprocore
 
PPTX
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
PPTX
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Pitch ...
Michele Kryston
 
PPTX
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Poster...
Michele Kryston
 
PDF
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
yosra Saidani
 
𝙳𝚘𝚠𝚗𝚕𝚘𝚊𝚍—Wondershare Filmora Crack 14.0.7 + Key Download 2025
sebastian aliya
 
ArcGIS Utility Network Migration - The Hunter Water Story
Safe Software
 
FME as an Orchestration Tool with Principles From Data Gravity
Safe Software
 
“Scaling i.MX Applications Processors’ Native Edge AI with Discrete AI Accele...
Edge AI and Vision Alliance
 
Enabling the Digital Artisan – keynote at ICOCI 2025
Alan Dix
 
UiPath Agentic AI ile Akıllı Otomasyonun Yeni Çağı
UiPathCommunity
 
The Future of Product Management in AI ERA.pdf
Alyona Owens
 
01_Approach Cyber- DORA Incident Management.pptx
FinTech Belgium
 
Simplifica la seguridad en la nube y la detección de amenazas con FortiCNAPP
Cristian Garcia G.
 
The Growing Value and Application of FME & GenAI
Safe Software
 
Cracking the Code - Unveiling Synergies Between Open Source Security and AI.pdf
Priyanka Aash
 
Automating the Geo-Referencing of Historic Aerial Photography in Flanders
Safe Software
 
Plugging AI into everything: Model Context Protocol Simplified.pdf
Abati Adewale
 
LLM Search Readiness Audit - Dentsu x SEO Square - June 2025.pdf
Nick Samuel
 
Practical Applications of AI in Local Government
OnBoard
 
CapCut Pro Crack For PC Latest Version {Fully Unlocked} 2025
pcprocore
 
Curietech AI in action - Accelerate MuleSoft development
shyamraj55
 
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Pitch ...
Michele Kryston
 
MARTSIA: A Tool for Confidential Data Exchange via Public Blockchain - Poster...
Michele Kryston
 
Salesforce Summer '25 Release Frenchgathering.pptx.pdf
yosra Saidani
 

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.