SlideShare ist ein Scribd-Unternehmen logo
1 von 15
Downloaden Sie, um offline zu lesen
Programming in Java
Lecture 14: Packages
By
Ravi Kant Sahu
Asst. Professor
Lovely Professional University, PunjabLovely Professional University, Punjab
Introduction
What is Package?
• A package is a namespace that organizes a set of related classes
and interfaces.
Or
• A Java package is a mechanism for organizing Java classes into
namespaces.
• A package is a logical container of classes, interfaces and sub-
packages.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Package
• Package provides unique namespace for classes (i.e. facility of
uniquely identifying a class or interface and resolving name
conflicts).
• If a class or interface is stored in a package, then it is
referenced by using the package name.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Introduction
What is the need of Package?
• A unique name should be used for each class to avoid name
collisions.
• Without some way to manage the name space, we could run out
of convenient, descriptive names for individual classes.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Reasons to use packages
• Grouping related classes.
• In large programs prevents name conflicts.
• Allows effective use of default "package" visibility.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Defining a Package
• Each file may have a package declaration which precedes all
non-comment code.
• The package name must be the same as the enclosing
directory.
• Default package:
If a package declaration is omitted, all
classes in that directory are said to belong to the "default"
package.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Defining a Package
• package Package_Name;
must be the first statement in a class or interface definition.
Example:
package P1;
public class Test
{
public static void main(String arr[])
{
System.out.println(“This is package P1”);
}
}
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Compilation:
Package P1> javac Test.java
Execution:
Package> java P1.Test
Note: To execute the class file of a package, we need to go back
to the parent folder of package and refer the class as-
package_name.class_name
• We can create the package while compiling the program.
javac –d . Test.java
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
classes in different packages
package P1;
public class Test11
{ public void display()
{System.out.println(“This is package P1”);}
}
package P2;
import P1.Test11;
public class Test1 {
public static void main(String arr[]) {
P1.Test 11 t = new P1.Test11();
t.display(); }
}
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
• ‘import’ keyword is used to import the classes of one package
into another package.
import package_name.*;
• A class must be publically defined in the package in order to
be imported in other package.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Importing a Package
• Once a class is imported in any package, it can be referenced
without package name.
• If a class is imported but not referenced in importing class,
then it will not be loaded (i.e. the imported class will be
loaded only when it is referenced ).
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Core Packages in Java
java.lang : basic language functionality and fundamental types
java.util : collection data structure classes
java.io : file operations
java.math : multiprecision arithmetics
java.nio : the New I/O framework for Java
java.net : networking operations, sockets
java.security : key generation, encryption and decryption
java.sql : Java Database Connectivity (JDBC) to access databases
java.awt : basic hierarchy of packages for native GUI components
javax.swing : hierarchy of packages for platform-independent rich
GUI components
java.applet : classes for creating an applet
Note: The java.lang package is available without the use of an import
statement.
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Access Specifiers
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Access Specifiers
Specifier Sub class
(Same
Package)
Non-Sub class
(Same
Package)
Sub class
(Different
Package)
Non-Sub class
(Different
Package)
Public Yes Yes Yes Yes
Protected Yes Yes Yes No
default Yes Yes No No
Private No No No No
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)

Weitere ähnliche Inhalte

Was ist angesagt?

Was ist angesagt? (20)

Packages and Interfaces
Packages and InterfacesPackages and Interfaces
Packages and Interfaces
 
Java Inheritance - sub class constructors - Method overriding
Java Inheritance - sub class constructors - Method overridingJava Inheritance - sub class constructors - Method overriding
Java Inheritance - sub class constructors - Method overriding
 
Distributed Programming (RMI)
Distributed Programming (RMI)Distributed Programming (RMI)
Distributed Programming (RMI)
 
Access modifiers in java
Access modifiers in javaAccess modifiers in java
Access modifiers in java
 
Cs8392 oops 5 units notes
Cs8392 oops 5 units notes Cs8392 oops 5 units notes
Cs8392 oops 5 units notes
 
Unit3 part3-packages and interfaces
Unit3 part3-packages and interfacesUnit3 part3-packages and interfaces
Unit3 part3-packages and interfaces
 
Java interview questions 2
Java interview questions 2Java interview questions 2
Java interview questions 2
 
java packages
java packagesjava packages
java packages
 
Java access modifiers
Java access modifiersJava access modifiers
Java access modifiers
 
Object+oriented+programming+in+java
Object+oriented+programming+in+javaObject+oriented+programming+in+java
Object+oriented+programming+in+java
 
Java interface
Java interfaceJava interface
Java interface
 
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
 
Basic Java Programming
Basic Java ProgrammingBasic Java Programming
Basic Java Programming
 
Basics of Java
Basics of JavaBasics of Java
Basics of Java
 
Java packages
Java packagesJava packages
Java packages
 
Unit 3 Java
Unit 3 JavaUnit 3 Java
Unit 3 Java
 
Java packages
Java packagesJava packages
Java packages
 
Pi j4.1 packages
Pi j4.1 packagesPi j4.1 packages
Pi j4.1 packages
 
Core java notes with examples
Core java notes with examplesCore java notes with examples
Core java notes with examples
 

Andere mochten auch (14)

Event handling
Event handlingEvent handling
Event handling
 
Sms several papers
Sms several papersSms several papers
Sms several papers
 
Networking
NetworkingNetworking
Networking
 
Jun 2012(1)
Jun 2012(1)Jun 2012(1)
Jun 2012(1)
 
List classes
List classesList classes
List classes
 
Collection framework
Collection frameworkCollection framework
Collection framework
 
Questions for Class I & II
Questions for Class I & IIQuestions for Class I & II
Questions for Class I & II
 
Basic IO
Basic IOBasic IO
Basic IO
 
Swing api
Swing apiSwing api
Swing api
 
Jdbc
JdbcJdbc
Jdbc
 
Multi threading
Multi threadingMulti threading
Multi threading
 
Servlets
ServletsServlets
Servlets
 
Classes and Nested Classes in Java
Classes and Nested Classes in JavaClasses and Nested Classes in Java
Classes and Nested Classes in Java
 
Generics
GenericsGenerics
Generics
 

Ähnlich wie Packages (20)

packages.ppt
packages.pptpackages.ppt
packages.ppt
 
Java - Packages Concepts
Java - Packages ConceptsJava - Packages Concepts
Java - Packages Concepts
 
Packages in java
Packages in javaPackages in java
Packages in java
 
javapackage
javapackagejavapackage
javapackage
 
Packages in java
Packages in javaPackages in java
Packages in java
 
Packages in java
Packages in javaPackages in java
Packages in java
 
Package in Java
Package in JavaPackage in Java
Package in Java
 
packages.ppt
packages.pptpackages.ppt
packages.ppt
 
packages.ppt
packages.pptpackages.ppt
packages.ppt
 
Java package
Java packageJava package
Java package
 
Packages in java
Packages in javaPackages in java
Packages in java
 
Packages
PackagesPackages
Packages
 
Javapackages 4th semester
Javapackages 4th semesterJavapackages 4th semester
Javapackages 4th semester
 
Packages
PackagesPackages
Packages
 
THE PACKAGES CONCEPT IN JAVA PROGRAMMING.pptx
THE PACKAGES CONCEPT  IN JAVA PROGRAMMING.pptxTHE PACKAGES CONCEPT  IN JAVA PROGRAMMING.pptx
THE PACKAGES CONCEPT IN JAVA PROGRAMMING.pptx
 
packages unit 5 .ppt
packages  unit 5 .pptpackages  unit 5 .ppt
packages unit 5 .ppt
 
7.Packages and Interfaces(MB).ppt .
7.Packages and Interfaces(MB).ppt             .7.Packages and Interfaces(MB).ppt             .
7.Packages and Interfaces(MB).ppt .
 
Packages
PackagesPackages
Packages
 
Packages in java
Packages in javaPackages in java
Packages in java
 
9 cm604.26
9 cm604.269 cm604.26
9 cm604.26
 

Mehr von Ravi Kant Sahu

String handling(string buffer class)
String handling(string buffer class)String handling(string buffer class)
String handling(string buffer class)Ravi Kant Sahu
 
String handling(string class)
String handling(string class)String handling(string class)
String handling(string class)Ravi Kant Sahu
 
Introduction to Java Programming
Introduction to Java ProgrammingIntroduction to Java Programming
Introduction to Java ProgrammingRavi Kant Sahu
 

Mehr von Ravi Kant Sahu (6)

Java beans
Java beansJava beans
Java beans
 
Applets
AppletsApplets
Applets
 
Exception handling
Exception handlingException handling
Exception handling
 
String handling(string buffer class)
String handling(string buffer class)String handling(string buffer class)
String handling(string buffer class)
 
String handling(string class)
String handling(string class)String handling(string class)
String handling(string class)
 
Introduction to Java Programming
Introduction to Java ProgrammingIntroduction to Java Programming
Introduction to Java Programming
 

Kürzlich hochgeladen

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerThousandEyes
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoffsammart93
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Jeffrey Haguewood
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Victor Rentea
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024The Digital Insurer
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdfSandro Moreira
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...DianaGray10
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamUiPathCommunity
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MIND CTI
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobeapidays
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfOrbitshub
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024The Digital Insurer
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDropbox
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfsudhanshuwaghmare1
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKJago de Vreede
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingEdi Saputra
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodJuan lago vázquez
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024The Digital Insurer
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyKhushali Kathiriya
 

Kürzlich hochgeladen (20)

How to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected WorkerHow to Troubleshoot Apps for the Modern Connected Worker
How to Troubleshoot Apps for the Modern Connected Worker
 
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot TakeoffStrategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
Strategize a Smooth Tenant-to-tenant Migration and Copilot Takeoff
 
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
Web Form Automation for Bonterra Impact Management (fka Social Solutions Apri...
 
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
Modular Monolith - a Practical Alternative to Microservices @ Devoxx UK 2024
 
FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024FWD Group - Insurer Innovation Award 2024
FWD Group - Insurer Innovation Award 2024
 
[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf[BuildWithAI] Introduction to Gemini.pdf
[BuildWithAI] Introduction to Gemini.pdf
 
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
Connector Corner: Accelerate revenue generation using UiPath API-centric busi...
 
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 AmsterdamDEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
DEV meet-up UiPath Document Understanding May 7 2024 Amsterdam
 
MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024MINDCTI Revenue Release Quarter One 2024
MINDCTI Revenue Release Quarter One 2024
 
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, AdobeApidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
Apidays New York 2024 - Scaling API-first by Ian Reasor and Radu Cotescu, Adobe
 
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdfRising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
Rising Above_ Dubai Floods and the Fortitude of Dubai International Airport.pdf
 
Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024Axa Assurance Maroc - Insurer Innovation Award 2024
Axa Assurance Maroc - Insurer Innovation Award 2024
 
DBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor PresentationDBX First Quarter 2024 Investor Presentation
DBX First Quarter 2024 Investor Presentation
 
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
+971581248768>> SAFE AND ORIGINAL ABORTION PILLS FOR SALE IN DUBAI AND ABUDHA...
 
Boost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdfBoost Fertility New Invention Ups Success Rates.pdf
Boost Fertility New Invention Ups Success Rates.pdf
 
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUKSpring Boot vs Quarkus the ultimate battle - DevoxxUK
Spring Boot vs Quarkus the ultimate battle - DevoxxUK
 
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost SavingRepurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
Repurposing LNG terminals for Hydrogen Ammonia: Feasibility and Cost Saving
 
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin WoodPolkadot JAM Slides - Token2049 - By Dr. Gavin Wood
Polkadot JAM Slides - Token2049 - By Dr. Gavin Wood
 
Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024Manulife - Insurer Transformation Award 2024
Manulife - Insurer Transformation Award 2024
 
Artificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : UncertaintyArtificial Intelligence Chap.5 : Uncertainty
Artificial Intelligence Chap.5 : Uncertainty
 

Packages

  • 1. Programming in Java Lecture 14: Packages By Ravi Kant Sahu Asst. Professor Lovely Professional University, PunjabLovely Professional University, Punjab
  • 2. Introduction What is Package? • A package is a namespace that organizes a set of related classes and interfaces. Or • A Java package is a mechanism for organizing Java classes into namespaces. • A package is a logical container of classes, interfaces and sub- packages. Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 3. Package • Package provides unique namespace for classes (i.e. facility of uniquely identifying a class or interface and resolving name conflicts). • If a class or interface is stored in a package, then it is referenced by using the package name. Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 4. Introduction What is the need of Package? • A unique name should be used for each class to avoid name collisions. • Without some way to manage the name space, we could run out of convenient, descriptive names for individual classes. Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 5. Reasons to use packages • Grouping related classes. • In large programs prevents name conflicts. • Allows effective use of default "package" visibility. Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 6. Defining a Package • Each file may have a package declaration which precedes all non-comment code. • The package name must be the same as the enclosing directory. • Default package: If a package declaration is omitted, all classes in that directory are said to belong to the "default" package. Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 7. Defining a Package • package Package_Name; must be the first statement in a class or interface definition. Example: package P1; public class Test { public static void main(String arr[]) { System.out.println(“This is package P1”); } } Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 8. Compilation: Package P1> javac Test.java Execution: Package> java P1.Test Note: To execute the class file of a package, we need to go back to the parent folder of package and refer the class as- package_name.class_name • We can create the package while compiling the program. javac –d . Test.java Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 9. classes in different packages package P1; public class Test11 { public void display() {System.out.println(“This is package P1”);} } package P2; import P1.Test11; public class Test1 { public static void main(String arr[]) { P1.Test 11 t = new P1.Test11(); t.display(); } } Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 10. • ‘import’ keyword is used to import the classes of one package into another package. import package_name.*; • A class must be publically defined in the package in order to be imported in other package. Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India) Importing a Package
  • 11. • Once a class is imported in any package, it can be referenced without package name. • If a class is imported but not referenced in importing class, then it will not be loaded (i.e. the imported class will be loaded only when it is referenced ). Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 12. Core Packages in Java java.lang : basic language functionality and fundamental types java.util : collection data structure classes java.io : file operations java.math : multiprecision arithmetics java.nio : the New I/O framework for Java java.net : networking operations, sockets java.security : key generation, encryption and decryption java.sql : Java Database Connectivity (JDBC) to access databases java.awt : basic hierarchy of packages for native GUI components javax.swing : hierarchy of packages for platform-independent rich GUI components java.applet : classes for creating an applet Note: The java.lang package is available without the use of an import statement. Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 13. Access Specifiers Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 14. Access Specifiers Specifier Sub class (Same Package) Non-Sub class (Same Package) Sub class (Different Package) Non-Sub class (Different Package) Public Yes Yes Yes Yes Protected Yes Yes Yes No default Yes Yes No No Private No No No No Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)
  • 15. Ravi Kant Sahu, Asst. Professor @ Lovely Professional University, Punjab (India)