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
PPTX
Basics of java (1)
PDF
PPTX
Javascript Road Trip(es6)
PPTX
Generics In and Out
PPTX
Java Tutorial Lab 6
DOCX
Differences between method overloading and method overriding
PDF
Packages
JAVA VIRTUAL MACHINE
Basics of java (1)
Javascript Road Trip(es6)
Generics In and Out
Java Tutorial Lab 6
Differences between method overloading and method overriding
Packages

What's hot (14)

PPTX
Java Tutorial Lab 4
PPT
11 advance inheritance_concepts
PPTX
Java Tutorial Lab 3
PPTX
ICOM4015 CIIC4010 Exam Review #1
PPTX
Chap2java5th
PPTX
Abstract classes & interfaces
PPTX
Semantic DEX Components
PPT
Byte stream classes.49
PPT
Reflection in C Sharp
DOCX
Math statemnt
PDF
ITFT - Java
PPTX
Static keyword ppt
PPTX
Reflection power pointpresentation ppt
Java Tutorial Lab 4
11 advance inheritance_concepts
Java Tutorial Lab 3
ICOM4015 CIIC4010 Exam Review #1
Chap2java5th
Abstract classes & interfaces
Semantic DEX Components
Byte stream classes.49
Reflection in C Sharp
Math statemnt
ITFT - Java
Static keyword ppt
Reflection power pointpresentation ppt
Ad

Similar to Static Import and access modifiers (20)

PPTX
OCA Java SE 8 Exam Chapter 4 Methods Encapsulation
PPTX
Imp Key.pptx very easy to learn go for it
PPTX
Closer look at classes
PPTX
class as the basis.pptx
DOCX
Java sessionnotes
PPTX
Class and Object.pptx from nit patna ece department
PDF
Class and Object JAVA PROGRAMMING LANG .pdf
PPTX
Hemajava
PDF
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
PPTX
PPT Lecture-1.4.pptx
PPT
Md03 - part3
PPT
Explain Classes and methods in java (ch04).ppt
PDF
7. VARIABLEs presentation in java programming. Pdf
PPTX
CJP Unit-1 contd.pptx
PDF
CHAPTER 3 part1.pdf
PPTX
Computer programming 2 Lesson 6
PPTX
PPTX
Std 12 computer chapter 8 classes and object in java (part 2)
PPTX
FINAL_DAY8_VISIBILITY_LABELS_Roles and.pptx
OCA Java SE 8 Exam Chapter 4 Methods Encapsulation
Imp Key.pptx very easy to learn go for it
Closer look at classes
class as the basis.pptx
Java sessionnotes
Class and Object.pptx from nit patna ece department
Class and Object JAVA PROGRAMMING LANG .pdf
Hemajava
Chapter 02: Classes Objects and Methods Java by Tushar B Kute
PPT Lecture-1.4.pptx
Md03 - part3
Explain Classes and methods in java (ch04).ppt
7. VARIABLEs presentation in java programming. Pdf
CJP Unit-1 contd.pptx
CHAPTER 3 part1.pdf
Computer programming 2 Lesson 6
Std 12 computer chapter 8 classes and object in java (part 2)
FINAL_DAY8_VISIBILITY_LABELS_Roles and.pptx
Ad

More from Maitree Patel (11)

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

Recently uploaded (20)

PPTX
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
PPTX
web development for engineering and engineering
PDF
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
PDF
Well-logging-methods_new................
PPTX
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
PDF
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
PPTX
CH1 Production IntroductoryConcepts.pptx
PDF
composite construction of structures.pdf
PPTX
Geodesy 1.pptx...............................................
PPTX
UNIT 4 Total Quality Management .pptx
PDF
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
PPTX
additive manufacturing of ss316l using mig welding
PDF
Operating System & Kernel Study Guide-1 - converted.pdf
PPTX
Welding lecture in detail for understanding
PDF
PPT on Performance Review to get promotions
PPTX
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
PDF
Automation-in-Manufacturing-Chapter-Introduction.pdf
PDF
Digital Logic Computer Design lecture notes
PPTX
Construction Project Organization Group 2.pptx
PPTX
OOP with Java - Java Introduction (Basics)
IOT PPTs Week 10 Lecture Material.pptx of NPTEL Smart Cities contd
web development for engineering and engineering
PRIZ Academy - 9 Windows Thinking Where to Invest Today to Win Tomorrow.pdf
Well-logging-methods_new................
Engineering Ethics, Safety and Environment [Autosaved] (1).pptx
Mitigating Risks through Effective Management for Enhancing Organizational Pe...
CH1 Production IntroductoryConcepts.pptx
composite construction of structures.pdf
Geodesy 1.pptx...............................................
UNIT 4 Total Quality Management .pptx
SM_6th-Sem__Cse_Internet-of-Things.pdf IOT
additive manufacturing of ss316l using mig welding
Operating System & Kernel Study Guide-1 - converted.pdf
Welding lecture in detail for understanding
PPT on Performance Review to get promotions
CARTOGRAPHY AND GEOINFORMATION VISUALIZATION chapter1 NPTE (2).pptx
Automation-in-Manufacturing-Chapter-Introduction.pdf
Digital Logic Computer Design lecture notes
Construction Project Organization Group 2.pptx
OOP with Java - Java Introduction (Basics)

Static Import and access modifiers