SlideShare a Scribd company logo
Object Oriented Programming Language
Vadodara Institute of Engineering
Active Learning Assignment
Topic: Static Import and Access Control
Computer Engineering
Presented By:
Kashyap Patel 150800107046
Krishna Patel 150800107047
Maitree Patel 150800107048
1
Contents
 Static Import
 Access control
2
Static Import
• Static Import is a new feature added in java.
• In order to access static members, it is necessary to qualify
references with the class they came from.
• That means in order to access the static members of a class, it is
a must to write the member along with its belonging class
name.
3
Static Import
 For Example:
class A
{
Public static void main(String a[])
{
Int a=36;
Int val=Math.sqrt(a);
4
Static Import
System.out.println(“The square root of”+a”is”+val);
}
}
o/p : The square root of 36 is 6
In order to avoid unnecessary use of static class members like
Math and System, we should Static import.
5
Static Import
Import static java.lang.System.out;
Import static java.lang.Math.sqrt;
class A
{
Public static void main(String a[])
{
6
Static Import
Int a=36;
Int val=sqrt(a);
System.out.println(“the square root of”+a”is”+val);
}
}
• O/p : the square root of 36 is 6
7
Static Import
• Note that ambiguous static import is not allowed.
• That means two different classes referencing the same
functionality is not allowed.
Advantage:
• The advantage of using static import is that readability of the
code increases as it avoids writing of belonging class name
each time. 8
Access control
• Access specifiers: visibility modifiers.
– Private
– default
– protected
– public
• these specifiers specify the scope .
9
Access control
• Private members can be accessed within the class where they
are declared. They are not allowed outside the class.
• Top level classes can be default and public but not private
• we can use these 4 specifies for all the members of the class
• these specifiers are not allowed for local variables
10
Access control
Class A
{
private int a;
Void set_a(int i)
{
A=I; }}
Declared
private
11
Access control
class B extends A
{ int b;
Void set_b(int i)
{ B=i; }
Void mul()
{ Int c;
12
Access control
C=a*b;
System.out.println(“mul is”+c);}}
class xyz
{
Public static void main(String a[])
{
13
Access control
A a=new A;
B b=new B;
b.set_a(10);
b.set_b(4);
b.mul();
} }
14
References
• https://www.tutorialspoint.com/java/java_access_modifiers.htm
• https://www.javatpoint.com/static-import-in-java
15
Thank You
16

More Related Content

PPSX
JAVA VIRTUAL MACHINE
Aadil Ansari
 
PPTX
Basics of java (1)
raj upadhyay
 
PDF
17515
Harish Khodke
 
PPTX
Javascript Road Trip(es6)
Ahmed Assaf
 
PPTX
Generics In and Out
Jaliya Udagedara
 
PPTX
Java Tutorial Lab 6
Berk Soysal
 
DOCX
Differences between method overloading and method overriding
Pinky Anaya
 
PDF
Packages
Ravi Kant Sahu
 
JAVA VIRTUAL MACHINE
Aadil Ansari
 
Basics of java (1)
raj upadhyay
 
Javascript Road Trip(es6)
Ahmed Assaf
 
Generics In and Out
Jaliya Udagedara
 
Java Tutorial Lab 6
Berk Soysal
 
Differences between method overloading and method overriding
Pinky Anaya
 
Packages
Ravi Kant Sahu
 

What's hot (14)

PPTX
Java Tutorial Lab 4
Berk Soysal
 
PPT
11 advance inheritance_concepts
Arriz San Juan
 
PPTX
Java Tutorial Lab 3
Berk Soysal
 
PPTX
ICOM4015 CIIC4010 Exam Review #1
Harry Hernández Rivera
 
PPTX
Chap2java5th
Asfand Hassan
 
PPTX
Abstract classes & interfaces
moazamali28
 
PPTX
Semantic DEX Components
David Price
 
PPT
Byte stream classes.49
myrajendra
 
PPT
Reflection in C Sharp
Harman Bajwa
 
DOCX
Math statemnt
E-Fiey Ghazali
 
PDF
ITFT - Java
Blossom Sood
 
PPTX
Static keyword ppt
Vinod Kumar
 
PPTX
Reflection power pointpresentation ppt
Rohit Vipin Mathews
 
Java Tutorial Lab 4
Berk Soysal
 
11 advance inheritance_concepts
Arriz San Juan
 
Java Tutorial Lab 3
Berk Soysal
 
ICOM4015 CIIC4010 Exam Review #1
Harry Hernández Rivera
 
Chap2java5th
Asfand Hassan
 
Abstract classes & interfaces
moazamali28
 
Semantic DEX Components
David Price
 
Byte stream classes.49
myrajendra
 
Reflection in C Sharp
Harman Bajwa
 
Math statemnt
E-Fiey Ghazali
 
ITFT - Java
Blossom Sood
 
Static keyword ppt
Vinod Kumar
 
Reflection power pointpresentation ppt
Rohit Vipin Mathews
 
Ad

Similar to Static Import and access modifiers (20)

PPTX
OCA Java SE 8 Exam Chapter 4 Methods Encapsulation
İbrahim Kürce
 
PPTX
Imp Key.pptx very easy to learn go for it
dwivedyp
 
PPTX
Closer look at classes
yugandhar vadlamudi
 
PPTX
class as the basis.pptx
Epsiba1
 
DOCX
Java sessionnotes
Lakshmi Sarvani Videla
 
PPTX
Class and Object.pptx from nit patna ece department
om2348023vats
 
PDF
Class and Object JAVA PROGRAMMING LANG .pdf
sameer2543ynr
 
PPTX
Hemajava
SangeethaSasi1
 
PDF
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Tushar B Kute
 
PPTX
PPT Lecture-1.4.pptx
HimanshuPandey957216
 
PPT
Md03 - part3
Rakesh Madugula
 
PPT
Explain Classes and methods in java (ch04).ppt
ayaankim007
 
PDF
7. VARIABLEs presentation in java programming. Pdf
simukondasankananji8
 
PPTX
CJP Unit-1 contd.pptx
RAJASEKHARV10
 
PDF
CHAPTER 3 part1.pdf
FacultyAnupamaAlagan
 
PPTX
Computer programming 2 Lesson 6
MLG College of Learning, Inc
 
PPTX
Java2
Ranjitham N
 
PPTX
Std 12 computer chapter 8 classes and object in java (part 2)
Nuzhat Memon
 
PPTX
FINAL_DAY8_VISIBILITY_LABELS_Roles and.pptx
VGaneshKarthikeyan
 
OCA Java SE 8 Exam Chapter 4 Methods Encapsulation
İbrahim Kürce
 
Imp Key.pptx very easy to learn go for it
dwivedyp
 
Closer look at classes
yugandhar vadlamudi
 
class as the basis.pptx
Epsiba1
 
Java sessionnotes
Lakshmi Sarvani Videla
 
Class and Object.pptx from nit patna ece department
om2348023vats
 
Class and Object JAVA PROGRAMMING LANG .pdf
sameer2543ynr
 
Hemajava
SangeethaSasi1
 
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
Tushar B Kute
 
PPT Lecture-1.4.pptx
HimanshuPandey957216
 
Md03 - part3
Rakesh Madugula
 
Explain Classes and methods in java (ch04).ppt
ayaankim007
 
7. VARIABLEs presentation in java programming. Pdf
simukondasankananji8
 
CJP Unit-1 contd.pptx
RAJASEKHARV10
 
CHAPTER 3 part1.pdf
FacultyAnupamaAlagan
 
Computer programming 2 Lesson 6
MLG College of Learning, Inc
 
Std 12 computer chapter 8 classes and object in java (part 2)
Nuzhat Memon
 
FINAL_DAY8_VISIBILITY_LABELS_Roles and.pptx
VGaneshKarthikeyan
 
Ad

More from Maitree Patel (11)

PPTX
MACs based on Hash Functions, MACs based on Block Ciphers
Maitree Patel
 
PPTX
Form using html and java script validation
Maitree Patel
 
PPT
Software engineering Testing technique,test case,test suit design
Maitree Patel
 
PPTX
Dotnet :Attributes
Maitree Patel
 
PPTX
Advance Java
Maitree Patel
 
PPTX
Introduction of Memory Management
Maitree Patel
 
PPTX
Scheduling Definition, objectives and types
Maitree Patel
 
PPTX
Simple Mail Transfer Protocol
Maitree Patel
 
PPTX
Virtual circuit and Datagram network
Maitree Patel
 
PPTX
Gauss Quadrature Formula
Maitree Patel
 
PPT
Merge sort and Quick sort
Maitree Patel
 
MACs based on Hash Functions, MACs based on Block Ciphers
Maitree Patel
 
Form using html and java script validation
Maitree Patel
 
Software engineering Testing technique,test case,test suit design
Maitree Patel
 
Dotnet :Attributes
Maitree Patel
 
Advance Java
Maitree Patel
 
Introduction of Memory Management
Maitree Patel
 
Scheduling Definition, objectives and types
Maitree Patel
 
Simple Mail Transfer Protocol
Maitree Patel
 
Virtual circuit and Datagram network
Maitree Patel
 
Gauss Quadrature Formula
Maitree Patel
 
Merge sort and Quick sort
Maitree Patel
 

Recently uploaded (20)

PPTX
Chapter_Seven_Construction_Reliability_Elective_III_Msc CM
SubashKumarBhattarai
 
PDF
top-5-use-cases-for-splunk-security-analytics.pdf
yaghutialireza
 
PPTX
Civil Engineering Practices_BY Sh.JP Mishra 23.09.pptx
bineetmishra1990
 
PDF
Biodegradable Plastics: Innovations and Market Potential (www.kiu.ac.ug)
publication11
 
PPTX
database slide on modern techniques for optimizing database queries.pptx
aky52024
 
PDF
Unit I Part II.pdf : Security Fundamentals
Dr. Madhuri Jawale
 
PDF
Cryptography and Information :Security Fundamentals
Dr. Madhuri Jawale
 
PPT
SCOPE_~1- technology of green house and poyhouse
bala464780
 
PPT
Ppt for engineering students application on field effect
lakshmi.ec
 
PPT
1. SYSTEMS, ROLES, AND DEVELOPMENT METHODOLOGIES.ppt
zilow058
 
PPTX
Information Retrieval and Extraction - Module 7
premSankar19
 
DOCX
SAR - EEEfdfdsdasdsdasdasdasdasdasdasdasda.docx
Kanimozhi676285
 
PDF
flutter Launcher Icons, Splash Screens & Fonts
Ahmed Mohamed
 
PPTX
FUNDAMENTALS OF ELECTRIC VEHICLES UNIT-1
MikkiliSuresh
 
PPTX
Inventory management chapter in automation and robotics.
atisht0104
 
PDF
Advanced LangChain & RAG: Building a Financial AI Assistant with Real-Time Data
Soufiane Sejjari
 
PDF
LEAP-1B presedntation xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
hatem173148
 
PDF
Packaging Tips for Stainless Steel Tubes and Pipes
heavymetalsandtubes
 
PDF
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
PDF
FLEX-LNG-Company-Presentation-Nov-2017.pdf
jbloggzs
 
Chapter_Seven_Construction_Reliability_Elective_III_Msc CM
SubashKumarBhattarai
 
top-5-use-cases-for-splunk-security-analytics.pdf
yaghutialireza
 
Civil Engineering Practices_BY Sh.JP Mishra 23.09.pptx
bineetmishra1990
 
Biodegradable Plastics: Innovations and Market Potential (www.kiu.ac.ug)
publication11
 
database slide on modern techniques for optimizing database queries.pptx
aky52024
 
Unit I Part II.pdf : Security Fundamentals
Dr. Madhuri Jawale
 
Cryptography and Information :Security Fundamentals
Dr. Madhuri Jawale
 
SCOPE_~1- technology of green house and poyhouse
bala464780
 
Ppt for engineering students application on field effect
lakshmi.ec
 
1. SYSTEMS, ROLES, AND DEVELOPMENT METHODOLOGIES.ppt
zilow058
 
Information Retrieval and Extraction - Module 7
premSankar19
 
SAR - EEEfdfdsdasdsdasdasdasdasdasdasdasda.docx
Kanimozhi676285
 
flutter Launcher Icons, Splash Screens & Fonts
Ahmed Mohamed
 
FUNDAMENTALS OF ELECTRIC VEHICLES UNIT-1
MikkiliSuresh
 
Inventory management chapter in automation and robotics.
atisht0104
 
Advanced LangChain & RAG: Building a Financial AI Assistant with Real-Time Data
Soufiane Sejjari
 
LEAP-1B presedntation xxxxxxxxxxxxxxxxxxxxxxxxxxxxx
hatem173148
 
Packaging Tips for Stainless Steel Tubes and Pipes
heavymetalsandtubes
 
67243-Cooling and Heating & Calculation.pdf
DHAKA POLYTECHNIC
 
FLEX-LNG-Company-Presentation-Nov-2017.pdf
jbloggzs
 

Static Import and access modifiers