Professional Documents
Culture Documents
INTERFACES IN
JAVA
Submitted To-: Submitted By-:
Dr Geeta Rani Vinay Sharma (2010981550)
Assistant professor Phalesh (2010981543)
INTERFACE
• A Java interface is a collection of abstract S
methods and
constants
• An abstract method is a method header without a
method body
• An abstract method can be declared using the modifier
abstract, but because all methods in an interface are
abstract, usually it is left off
• An interface is used to establish a set of methods that a
class will implement
Interfaces
interface is a reserved word
None of the methods in
an interface are given
public interface Doable a definition (body)
{
public void doThis();
public int doThat();
public void doThis2 (float value, char ch);
public boolean doTheOther (int num);
}
A semicolon immediately
follows each method header
Interfaces
.An interface cannot be instantiated
.Methods in an interface have public visibility by default
.A class formally implements an interface by:
◦ stating so in the class header
◦ providing implementations for each abstract method in the
interface
A. Classes
B. Sub Packages
C. Interfaces
D. All of the above
A. pkg
B. Pkg
C. package
D. Package
3. Package names and directory structure are closely related.
A. TRUE
B. FALSE
C. can be true or false
D. can not say
4. An _______________ statement can be used to access the classes and interface of a different package
from the current package.
A. instanceOf
B. import
C. extends
D. implement
5. Which of the following packages is used to includes classes to create user interface like Button and
Checkbox?
A. java.lang
B. java.net
C. java.awt
D. java.io