SlideShare a Scribd company logo
1 of 22
PACKAGES
Dr.K.Kalaiselvi
Dept.of Computer Science
Kristu Jayanti college,
Bangalore
• Package in Java is a mechanism to encapsulate a group of classes, sub
packages and interfaces.
• Packages are used for:
• Preventing naming conflicts. For example there can be two classes
with same name in two packages,
• Makes searching/locating and usage of classes, interfaces,
enumerations and annotations easier
• Providing controlled access: protected and default have package level
access control. Aprotected member is accessible by classes in the
same package and its subclasses. Adefault member (without any
access specifier) is accessible by classes in the same package only.
• Packages that are inside another package are the subpackages. These
are not imported by default, they have to imported explicitly.
User-defined packages
These are the packages that are defined by the user. First we create a
directory mypack . Then create the class Simple inside the directory with the first
statement being the package names.
//save as Simple.java
package mypack;
class SimplePackage{
public void display(){
System.out.println("Welcome to package");
}
}
import mypack.SimplePackage;
public class PackageUse
{
public static void main(String args[])
{
SimplePackage p=new SimplePackage();
p.display();
}
}
To compile java package:
javac -d . Simple.java / / -d specifies the destination where to putthe
generated class file, to keep the package within the same directory use . (dot).
To Compile: javac -d . Simple.java
To Run: java mypack.Simple
• It is a collection of abstract methods. Aclass implements an interface, thereby
inheriting the abstract methods of the interface.
• Interface cannot be instantiated.
• An interface does not contain any constructors.
• All of the methods in an interface are abstract.
• An interface is not extended by a class; it is implemented by a class.
• An interface can extend multiple interfaces.
• Interface methods do not have a body - the body is provided by the
"implement" class
• On implementation of an interface, you must override all of its methods
• Interface methods are by default abstract and public
• Interface attributes are by default public, static and final
• To achieve security - hide certain details and only show the important details
of an object
• "multiple inheritance" can be achieved with interfaces, because the class
can implement multiple interfaces.
INTERFACES IN JA
V
A
by default.
interface <interface_name>{
/ / declare constant fields
/ / declare methods thatabstract
}
The Java compiler adds public and abstract keywords before the interface
method. Moreover, it adds public, static and final keywords before data
members.
a class extends another class, an interface extends another interface, but
a class implements an interface.
Aclass can extend only one class, but implement many interfaces..
interface In1
{
/ / public, static andfinal final int a =
10;
/ / public and abstract void
display();
}
class InterfaceTestClass implements In1
{
/ / Implementing the capabilities of interface.
public void display()
{
System.out.println(“Kristu Jayanti College");
}
public static void main (String[] args)
{
InterfaceTestClass t = new InterfaceTestClass(); t.display();
System.out.println(a);
}
• Aclass can implement more than one interface at a time.
• Aclass can extend only one class, but implement many interfaces.
• An interface can extend another interface, in a similar wayas a class can
extend another class.
• If a class implements multiple interfaces, or an interface extends multiple
interfaces, it is known as multiple inheritance.
interface FirstInterface {
public void myMethod(); / / interface method
}
interface SecondInterface {
public void myOtherMethod(); / / interface method
}
class DemoClass implements FirstInterface, SecondInterface {
public void myMethod() {
System.out.println("Some text from irst interface..");
}
public void myOtherMethod() { System.out.println("Some
text from second interface...");
}
}
class MulInterfaceTest1 {
public static void main(String[] args) {
DemoClass myObj = new DemoClass();
myObj.myMethod();
myObj.myOtherMethod();
}
• Multiple inheritance is not supported through class in java, but it is possible by an
interface, why?
• multiple inheritance is not supported in the case of class because of ambiguity. However,
it is supported in case of an interface because there is no ambiguity. It is because its
implementation is provided by the implementation class.
interface Printable{
void print();
}
interface Showable{
void print();
}
class TestInterface3 implementss Printable, Showable{
public void print(){System.out.println("Hello");}
public static void main(String args[]){
TestInterface3 obj = new TestInterface3();
obj.print();
} }
interface Printable{
void print();
}
interface Showable extends Printable{
void show();
}
class InterfaceInheritance implements Showable{
public void print(){System.out.println("Hello");}
public void show(){System.out.println("Welcome");}
public static void main(String args[]){
InterfaceInheritance obj = new InterfaceInheritance();
obj.print();
obj.show();
}
}
INTERFACE INHERITANCE
Provides classes that are fundamental to the design of the Java programming
language.
Object, the ultimate superclass of all classes in Java
• Thread, the class that controls each thread in a multithreaded program
• Throwable, the superclass of all error and exception classes in Java
• Classes that encapsulate the primitive data types in Java
• Classes for accessing system resources and other low-level entities
• Math, a class that provides standard mathematical methods
• String, the class that is used to represent strings
Java.lang Package In Java
• Wrapper classes are those whose objects wraps a primitive data type within
them.
• In the java.lang package java provides a separate class for each of the
primitive data types namely Byte, Character, Double, Integer, Float, Long,
Short.
• At the time of instantiation, these classes accept a primitive datatype
directly, and wrap a primitive value into a wrapper class object.
• They convert primitive data types into objects.
• It contains the utility classes (a string tokenizer, a random-number generator, and a bit
array).
• AbstractCollection: This class provides a skeletal implementation of the Collection
interface, to minimize the effort required to implement this interface.
• Arrays: This class contains various methods for manipulating arrays (such as sorting and
searching).
• Calendar: The Calendar class is an abstract class that provides methods for converting
between a specific instant in time and a set of calendar fields such as YEAR, MONTH,
DAY_OF_MONTH, HOUR,
• Currency: Represents a currency.
• Date: The class Date represents a specific instant in time, with millisecond precision.
• Random: An instance of this class is used to generate a stream of pseudorandom
numbers.
• Scanner: Asimple text scanner which can parse primitive types and strings using regular
expressions.
• String Tokenizer: The string tokenizer class allows an application to break a string into
tokens.
• Treeset: ANavigableSet implementation based on a TreeMap.
java.util PACKAGE
• This package provides for system input and output through data streams,
serialization and the file system.
• Java uses the concept of a stream to make I/O operation fast. The java.io
package contains all the classes required for input and output operations.
3 streams are created automatically.All these streams are attached with the
console.
1) System.out: standard output stream
2) System.in: standard input stream
3) System.err: standard error stream
JAVA.IOPACKAGEIN JA
V
A
Java.io.FileInputStream Class in Java
FileInputStream is useful to read data from a file in the form of sequence of
bytes.For reading streams of characters, consider using FileReader.
Constructor and Description
FileInputStream(File file) :Creates an input file stream to read from the
specified File object.
FileInputStream(FileDescriptor fdobj) :Creates an input file stream to read
from the specified file descriptor.
FileInputStream(String name) :Creates an input file stream to read from a file
with the specified name.
Important Methods:
int read() :Reads a byte of data from this input stream
int read(byte[] b) :Reads up to b.length bytes of data from this input stream into
an array of bytes.
int read(byte[] b, int off, int len) : Reads up to len bytes of data from this input
stream into an array of bytes.
void close() :Closes this file input stream and releases any system resources
associated with the stream.
• FileOutputStream is meant for writing streams of raw bytes
• It can be used to create text files.Afile represents storage of data on a
second storage media like a hard disk or CD. Whether or not a file is
available or may be created
void close() :Closes this file output stream and releases any system resources
associated with this stream.
protected void finalize() :Cleans up the connection to the file, and ensures
that the close method of this file output stream is called when there are no
more references to this stream.
void write(byte[] b) :Writes b.length bytes from the specified byte array to
this file output stream.
void write(byte[] b, int off, int len) :Writes len bytes from the specified
byte array starting at offset off to this file output stream.
void write(int b) :Writes the specified byte to this file output stream.

More Related Content

What's hot

packages and interfaces
packages and interfacespackages and interfaces
packages and interfacesmadhavi patil
 
Class notes(week 7) on packages
Class notes(week 7) on packagesClass notes(week 7) on packages
Class notes(week 7) on packagesKuntal Bhowmick
 
Java - Interfaces & Packages
Java - Interfaces & PackagesJava - Interfaces & Packages
Java - Interfaces & PackagesArindam Ghosh
 
Packages and Interfaces
Packages and InterfacesPackages and Interfaces
Packages and InterfacesAkashDas112
 
Object and Classes in Java
Object and Classes in JavaObject and Classes in Java
Object and Classes in Javabackdoor
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in javaTech_MX
 
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteChapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteTushar B Kute
 
Multiple inheritance possible in Java
Multiple inheritance possible in JavaMultiple inheritance possible in Java
Multiple inheritance possible in JavaKurapati Vishwak
 
Java: Inheritance
Java: InheritanceJava: Inheritance
Java: InheritanceTareq Hasan
 
java interface and packages
java interface and packagesjava interface and packages
java interface and packagesVINOTH R
 
java-06inheritance
java-06inheritancejava-06inheritance
java-06inheritanceArjun Shanka
 
Lecture - 2 Environment setup & JDK, JRE, JVM
Lecture - 2 Environment setup & JDK, JRE, JVMLecture - 2 Environment setup & JDK, JRE, JVM
Lecture - 2 Environment setup & JDK, JRE, JVMmanish kumar
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Javabackdoor
 

What's hot (20)

packages and interfaces
packages and interfacespackages and interfaces
packages and interfaces
 
Class notes(week 7) on packages
Class notes(week 7) on packagesClass notes(week 7) on packages
Class notes(week 7) on packages
 
Java packages
Java packagesJava packages
Java packages
 
Java - Interfaces & Packages
Java - Interfaces & PackagesJava - Interfaces & Packages
Java - Interfaces & Packages
 
Packages and Interfaces
Packages and InterfacesPackages and Interfaces
Packages and Interfaces
 
JAVA PROGRAMMING – Packages - Stream based I/O
JAVA PROGRAMMING – Packages - Stream based I/O JAVA PROGRAMMING – Packages - Stream based I/O
JAVA PROGRAMMING – Packages - Stream based I/O
 
Java API, Exceptions and IO
Java API, Exceptions and IOJava API, Exceptions and IO
Java API, Exceptions and IO
 
Java access modifiers
Java access modifiersJava access modifiers
Java access modifiers
 
Object and Classes in Java
Object and Classes in JavaObject and Classes in Java
Object and Classes in Java
 
Inheritance in java
Inheritance in javaInheritance in java
Inheritance in java
 
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B KuteChapter 02: Classes Objects and Methods Java by Tushar B Kute
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
 
Multiple inheritance possible in Java
Multiple inheritance possible in JavaMultiple inheritance possible in Java
Multiple inheritance possible in Java
 
Java: Inheritance
Java: InheritanceJava: Inheritance
Java: Inheritance
 
java interface and packages
java interface and packagesjava interface and packages
java interface and packages
 
java-06inheritance
java-06inheritancejava-06inheritance
java-06inheritance
 
java packages
java packagesjava packages
java packages
 
Interface
InterfaceInterface
Interface
 
Lecture - 2 Environment setup & JDK, JRE, JVM
Lecture - 2 Environment setup & JDK, JRE, JVMLecture - 2 Environment setup & JDK, JRE, JVM
Lecture - 2 Environment setup & JDK, JRE, JVM
 
Object Oriented Programming with Java
Object Oriented Programming with JavaObject Oriented Programming with Java
Object Oriented Programming with Java
 
Access modifiers in java
Access modifiers in javaAccess modifiers in java
Access modifiers in java
 

Similar to Unit3 packages &amp; interfaces

Similar to Unit3 packages &amp; interfaces (20)

Cse java
Cse javaCse java
Cse java
 
Synapseindia reviews.odp.
Synapseindia reviews.odp.Synapseindia reviews.odp.
Synapseindia reviews.odp.
 
object oriented programming using java, second sem BCA,UoM
object oriented programming using java, second sem BCA,UoMobject oriented programming using java, second sem BCA,UoM
object oriented programming using java, second sem BCA,UoM
 
Java tutorials
Java tutorialsJava tutorials
Java tutorials
 
Java programming basics
Java programming basicsJava programming basics
Java programming basics
 
Java mcq
Java mcqJava mcq
Java mcq
 
Inheritance
InheritanceInheritance
Inheritance
 
Core_Java_Interview.pdf
Core_Java_Interview.pdfCore_Java_Interview.pdf
Core_Java_Interview.pdf
 
Java For beginners and CSIT and IT students
Java  For beginners and CSIT and IT studentsJava  For beginners and CSIT and IT students
Java For beginners and CSIT and IT students
 
Packages and interfaces
Packages and interfacesPackages and interfaces
Packages and interfaces
 
Unit3 part1-class
Unit3 part1-classUnit3 part1-class
Unit3 part1-class
 
Java Tutorial 1
Java Tutorial 1Java Tutorial 1
Java Tutorial 1
 
Java-Intro.pptx
Java-Intro.pptxJava-Intro.pptx
Java-Intro.pptx
 
C# classes objects
C#  classes objectsC#  classes objects
C# classes objects
 
Module 1.pptx
Module 1.pptxModule 1.pptx
Module 1.pptx
 
ch4 foohggggvvbbhhhhhhhhhbbbbbbbbbbbbp.pdf
ch4 foohggggvvbbhhhhhhhhhbbbbbbbbbbbbp.pdfch4 foohggggvvbbhhhhhhhhhbbbbbbbbbbbbp.pdf
ch4 foohggggvvbbhhhhhhhhhbbbbbbbbbbbbp.pdf
 
Java interview questions
Java interview questionsJava interview questions
Java interview questions
 
JavaTutorials.ppt
JavaTutorials.pptJavaTutorials.ppt
JavaTutorials.ppt
 
LectureNotes-02-DSA
LectureNotes-02-DSALectureNotes-02-DSA
LectureNotes-02-DSA
 
Java interface
Java interfaceJava interface
Java interface
 

More from Kalai Selvi

cloud services and providers
cloud services and providerscloud services and providers
cloud services and providersKalai Selvi
 
cloud concepts and technologies
cloud concepts and technologiescloud concepts and technologies
cloud concepts and technologiesKalai Selvi
 
I Semester-Unit 3 Boolean Algebra.pptx
I Semester-Unit 3 Boolean Algebra.pptxI Semester-Unit 3 Boolean Algebra.pptx
I Semester-Unit 3 Boolean Algebra.pptxKalai Selvi
 
I semester-SOP-POS expressions.pptx
I semester-SOP-POS expressions.pptxI semester-SOP-POS expressions.pptx
I semester-SOP-POS expressions.pptxKalai Selvi
 
I Semester-Unit 3 Boolean Algebra.pptx
I Semester-Unit 3 Boolean Algebra.pptxI Semester-Unit 3 Boolean Algebra.pptx
I Semester-Unit 3 Boolean Algebra.pptxKalai Selvi
 
Multimedia Authoring Tools.ppt
Multimedia Authoring Tools.pptMultimedia Authoring Tools.ppt
Multimedia Authoring Tools.pptKalai Selvi
 
Process of Making Multimedia.ppt
Process of Making Multimedia.pptProcess of Making Multimedia.ppt
Process of Making Multimedia.pptKalai Selvi
 
Introduction to Artificial Intelligence
Introduction to Artificial IntelligenceIntroduction to Artificial Intelligence
Introduction to Artificial IntelligenceKalai Selvi
 
Searching techniques in AI
Searching techniques in AISearching techniques in AI
Searching techniques in AIKalai Selvi
 
Introduction to Artificial Intelligence
Introduction to Artificial IntelligenceIntroduction to Artificial Intelligence
Introduction to Artificial IntelligenceKalai Selvi
 
AWT controls, Listeners
AWT controls, ListenersAWT controls, Listeners
AWT controls, ListenersKalai Selvi
 
AWT controls, Listeners
AWT controls, ListenersAWT controls, Listeners
AWT controls, ListenersKalai Selvi
 
Unit 4 combinational circuit
Unit 4 combinational circuitUnit 4 combinational circuit
Unit 4 combinational circuitKalai Selvi
 
Unit 3 file management
Unit 3 file managementUnit 3 file management
Unit 3 file managementKalai Selvi
 
Unit 3 chapter 1-file management
Unit 3 chapter 1-file managementUnit 3 chapter 1-file management
Unit 3 chapter 1-file managementKalai Selvi
 
Unit 2chapter 2 memory mgmt complete
Unit 2chapter 2  memory mgmt completeUnit 2chapter 2  memory mgmt complete
Unit 2chapter 2 memory mgmt completeKalai Selvi
 

More from Kalai Selvi (19)

cloud services and providers
cloud services and providerscloud services and providers
cloud services and providers
 
cloud concepts and technologies
cloud concepts and technologiescloud concepts and technologies
cloud concepts and technologies
 
cloud computing
cloud computingcloud computing
cloud computing
 
I Semester-Unit 3 Boolean Algebra.pptx
I Semester-Unit 3 Boolean Algebra.pptxI Semester-Unit 3 Boolean Algebra.pptx
I Semester-Unit 3 Boolean Algebra.pptx
 
I semester-SOP-POS expressions.pptx
I semester-SOP-POS expressions.pptxI semester-SOP-POS expressions.pptx
I semester-SOP-POS expressions.pptx
 
I Semester-Unit 3 Boolean Algebra.pptx
I Semester-Unit 3 Boolean Algebra.pptxI Semester-Unit 3 Boolean Algebra.pptx
I Semester-Unit 3 Boolean Algebra.pptx
 
Multimedia Authoring Tools.ppt
Multimedia Authoring Tools.pptMultimedia Authoring Tools.ppt
Multimedia Authoring Tools.ppt
 
Process of Making Multimedia.ppt
Process of Making Multimedia.pptProcess of Making Multimedia.ppt
Process of Making Multimedia.ppt
 
Introduction to Artificial Intelligence
Introduction to Artificial IntelligenceIntroduction to Artificial Intelligence
Introduction to Artificial Intelligence
 
Searching techniques in AI
Searching techniques in AISearching techniques in AI
Searching techniques in AI
 
Introduction to Artificial Intelligence
Introduction to Artificial IntelligenceIntroduction to Artificial Intelligence
Introduction to Artificial Intelligence
 
AWT controls, Listeners
AWT controls, ListenersAWT controls, Listeners
AWT controls, Listeners
 
AWT controls, Listeners
AWT controls, ListenersAWT controls, Listeners
AWT controls, Listeners
 
Unit 1 part 2
Unit 1  part 2Unit 1  part 2
Unit 1 part 2
 
Unit 1 part 1
Unit 1   part 1Unit 1   part 1
Unit 1 part 1
 
Unit 4 combinational circuit
Unit 4 combinational circuitUnit 4 combinational circuit
Unit 4 combinational circuit
 
Unit 3 file management
Unit 3 file managementUnit 3 file management
Unit 3 file management
 
Unit 3 chapter 1-file management
Unit 3 chapter 1-file managementUnit 3 chapter 1-file management
Unit 3 chapter 1-file management
 
Unit 2chapter 2 memory mgmt complete
Unit 2chapter 2  memory mgmt completeUnit 2chapter 2  memory mgmt complete
Unit 2chapter 2 memory mgmt complete
 

Recently uploaded

Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Jisc
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Celine George
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxsqpmdrvczh
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxNirmalaLoungPoorunde1
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxiammrhaywood
 
Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........LeaCamillePacle
 
Quarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayQuarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayMakMakNepo
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxEyham Joco
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️9953056974 Low Rate Call Girls In Saket, Delhi NCR
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 
ROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationAadityaSharma884161
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfMr Bounab Samir
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...Nguyen Thanh Tu Collection
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPCeline George
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxChelloAnnAsuncion2
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfSpandanaRallapalli
 

Recently uploaded (20)

Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...Procuring digital preservation CAN be quick and painless with our new dynamic...
Procuring digital preservation CAN be quick and painless with our new dynamic...
 
Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17Difference Between Search & Browse Methods in Odoo 17
Difference Between Search & Browse Methods in Odoo 17
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
Romantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptxRomantic Opera MUSIC FOR GRADE NINE pptx
Romantic Opera MUSIC FOR GRADE NINE pptx
 
Employee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptxEmployee wellbeing at the workplace.pptx
Employee wellbeing at the workplace.pptx
 
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptxECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
ECONOMIC CONTEXT - PAPER 1 Q3: NEWSPAPERS.pptx
 
Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........Atmosphere science 7 quarter 4 .........
Atmosphere science 7 quarter 4 .........
 
Quarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up FridayQuarter 4 Peace-education.pptx Catch Up Friday
Quarter 4 Peace-education.pptx Catch Up Friday
 
Types of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptxTypes of Journalistic Writing Grade 8.pptx
Types of Journalistic Writing Grade 8.pptx
 
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
call girls in Kamla Market (DELHI) 🔝 >༒9953330565🔝 genuine Escort Service 🔝✔️✔️
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 
ROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint PresentationROOT CAUSE ANALYSIS PowerPoint Presentation
ROOT CAUSE ANALYSIS PowerPoint Presentation
 
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdfLike-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
Like-prefer-love -hate+verb+ing & silent letters & citizenship text.pdf
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
HỌC TỐT TIẾNG ANH 11 THEO CHƯƠNG TRÌNH GLOBAL SUCCESS ĐÁP ÁN CHI TIẾT - CẢ NĂ...
 
How to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERPHow to do quick user assign in kanban in Odoo 17 ERP
How to do quick user assign in kanban in Odoo 17 ERP
 
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptxGrade 9 Q4-MELC1-Active and Passive Voice.pptx
Grade 9 Q4-MELC1-Active and Passive Voice.pptx
 
ACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdfACC 2024 Chronicles. Cardiology. Exam.pdf
ACC 2024 Chronicles. Cardiology. Exam.pdf
 

Unit3 packages &amp; interfaces

  • 2. • Package in Java is a mechanism to encapsulate a group of classes, sub packages and interfaces. • Packages are used for: • Preventing naming conflicts. For example there can be two classes with same name in two packages, • Makes searching/locating and usage of classes, interfaces, enumerations and annotations easier • Providing controlled access: protected and default have package level access control. Aprotected member is accessible by classes in the same package and its subclasses. Adefault member (without any access specifier) is accessible by classes in the same package only. • Packages that are inside another package are the subpackages. These are not imported by default, they have to imported explicitly.
  • 3.
  • 4.
  • 5. User-defined packages These are the packages that are defined by the user. First we create a directory mypack . Then create the class Simple inside the directory with the first statement being the package names. //save as Simple.java package mypack; class SimplePackage{ public void display(){ System.out.println("Welcome to package"); } }
  • 6. import mypack.SimplePackage; public class PackageUse { public static void main(String args[]) { SimplePackage p=new SimplePackage(); p.display(); } } To compile java package: javac -d . Simple.java / / -d specifies the destination where to putthe generated class file, to keep the package within the same directory use . (dot). To Compile: javac -d . Simple.java To Run: java mypack.Simple
  • 7.
  • 8. • It is a collection of abstract methods. Aclass implements an interface, thereby inheriting the abstract methods of the interface. • Interface cannot be instantiated. • An interface does not contain any constructors. • All of the methods in an interface are abstract. • An interface is not extended by a class; it is implemented by a class. • An interface can extend multiple interfaces. • Interface methods do not have a body - the body is provided by the "implement" class • On implementation of an interface, you must override all of its methods • Interface methods are by default abstract and public • Interface attributes are by default public, static and final • To achieve security - hide certain details and only show the important details of an object • "multiple inheritance" can be achieved with interfaces, because the class can implement multiple interfaces. INTERFACES IN JA V A
  • 9. by default. interface <interface_name>{ / / declare constant fields / / declare methods thatabstract } The Java compiler adds public and abstract keywords before the interface method. Moreover, it adds public, static and final keywords before data members.
  • 10. a class extends another class, an interface extends another interface, but a class implements an interface. Aclass can extend only one class, but implement many interfaces..
  • 11. interface In1 { / / public, static andfinal final int a = 10; / / public and abstract void display(); } class InterfaceTestClass implements In1 { / / Implementing the capabilities of interface. public void display() { System.out.println(“Kristu Jayanti College"); } public static void main (String[] args) { InterfaceTestClass t = new InterfaceTestClass(); t.display(); System.out.println(a); }
  • 12. • Aclass can implement more than one interface at a time. • Aclass can extend only one class, but implement many interfaces. • An interface can extend another interface, in a similar wayas a class can extend another class. • If a class implements multiple interfaces, or an interface extends multiple interfaces, it is known as multiple inheritance.
  • 13. interface FirstInterface { public void myMethod(); / / interface method } interface SecondInterface { public void myOtherMethod(); / / interface method } class DemoClass implements FirstInterface, SecondInterface { public void myMethod() { System.out.println("Some text from irst interface.."); } public void myOtherMethod() { System.out.println("Some text from second interface..."); } } class MulInterfaceTest1 { public static void main(String[] args) { DemoClass myObj = new DemoClass(); myObj.myMethod(); myObj.myOtherMethod(); }
  • 14. • Multiple inheritance is not supported through class in java, but it is possible by an interface, why? • multiple inheritance is not supported in the case of class because of ambiguity. However, it is supported in case of an interface because there is no ambiguity. It is because its implementation is provided by the implementation class. interface Printable{ void print(); } interface Showable{ void print(); } class TestInterface3 implementss Printable, Showable{ public void print(){System.out.println("Hello");} public static void main(String args[]){ TestInterface3 obj = new TestInterface3(); obj.print(); } }
  • 15. interface Printable{ void print(); } interface Showable extends Printable{ void show(); } class InterfaceInheritance implements Showable{ public void print(){System.out.println("Hello");} public void show(){System.out.println("Welcome");} public static void main(String args[]){ InterfaceInheritance obj = new InterfaceInheritance(); obj.print(); obj.show(); } } INTERFACE INHERITANCE
  • 16. Provides classes that are fundamental to the design of the Java programming language. Object, the ultimate superclass of all classes in Java • Thread, the class that controls each thread in a multithreaded program • Throwable, the superclass of all error and exception classes in Java • Classes that encapsulate the primitive data types in Java • Classes for accessing system resources and other low-level entities • Math, a class that provides standard mathematical methods • String, the class that is used to represent strings Java.lang Package In Java
  • 17. • Wrapper classes are those whose objects wraps a primitive data type within them. • In the java.lang package java provides a separate class for each of the primitive data types namely Byte, Character, Double, Integer, Float, Long, Short. • At the time of instantiation, these classes accept a primitive datatype directly, and wrap a primitive value into a wrapper class object. • They convert primitive data types into objects.
  • 18.
  • 19. • It contains the utility classes (a string tokenizer, a random-number generator, and a bit array). • AbstractCollection: This class provides a skeletal implementation of the Collection interface, to minimize the effort required to implement this interface. • Arrays: This class contains various methods for manipulating arrays (such as sorting and searching). • Calendar: The Calendar class is an abstract class that provides methods for converting between a specific instant in time and a set of calendar fields such as YEAR, MONTH, DAY_OF_MONTH, HOUR, • Currency: Represents a currency. • Date: The class Date represents a specific instant in time, with millisecond precision. • Random: An instance of this class is used to generate a stream of pseudorandom numbers. • Scanner: Asimple text scanner which can parse primitive types and strings using regular expressions. • String Tokenizer: The string tokenizer class allows an application to break a string into tokens. • Treeset: ANavigableSet implementation based on a TreeMap. java.util PACKAGE
  • 20. • This package provides for system input and output through data streams, serialization and the file system. • Java uses the concept of a stream to make I/O operation fast. The java.io package contains all the classes required for input and output operations. 3 streams are created automatically.All these streams are attached with the console. 1) System.out: standard output stream 2) System.in: standard input stream 3) System.err: standard error stream JAVA.IOPACKAGEIN JA V A
  • 21. Java.io.FileInputStream Class in Java FileInputStream is useful to read data from a file in the form of sequence of bytes.For reading streams of characters, consider using FileReader. Constructor and Description FileInputStream(File file) :Creates an input file stream to read from the specified File object. FileInputStream(FileDescriptor fdobj) :Creates an input file stream to read from the specified file descriptor. FileInputStream(String name) :Creates an input file stream to read from a file with the specified name. Important Methods: int read() :Reads a byte of data from this input stream int read(byte[] b) :Reads up to b.length bytes of data from this input stream into an array of bytes. int read(byte[] b, int off, int len) : Reads up to len bytes of data from this input stream into an array of bytes. void close() :Closes this file input stream and releases any system resources associated with the stream.
  • 22. • FileOutputStream is meant for writing streams of raw bytes • It can be used to create text files.Afile represents storage of data on a second storage media like a hard disk or CD. Whether or not a file is available or may be created void close() :Closes this file output stream and releases any system resources associated with this stream. protected void finalize() :Cleans up the connection to the file, and ensures that the close method of this file output stream is called when there are no more references to this stream. void write(byte[] b) :Writes b.length bytes from the specified byte array to this file output stream. void write(byte[] b, int off, int len) :Writes len bytes from the specified byte array starting at offset off to this file output stream. void write(int b) :Writes the specified byte to this file output stream.