0% found this document useful (0 votes)
15 views

Java Color

java color

Uploaded by

Prince Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views

Java Color

java color

Uploaded by

Prince Kumar
Copyright
© © All Rights Reserved
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 26

1

QuesàWhat is object oriented programming language


discuss the feature of object oriented programming in
respect of java.
AnsàObject oriented programming is those type of programming
in which methods and instance variable allocate distinct memory in
different location and at the time of execution make a link between
them to create a complete object, which is the basic component of
the object oriented programming. Methods allocates there
respective memory at the time of class declaration and instance
variable allocates there memory at the time of object creation at
execution time. After allocation of memory by instance variable a
binding process is performed between methods and instance
variable after that a complete object is created which is the basic
component of the object oriented programming.
Object are that type of element which
can be uniquely identified using some identifying properties.
Alternately we can say that Object is that type of element which
can be distinguished from other element.
It is also possible to say that class type
variable is called object every object must have some identifying
properties to uniquely identify a particular object. The identifying
properties are called instance variable in java. So we can say that
object are the encapsulated form of methods and instance variable.
Every object must have some function to perform task. The
functions present in object are called methods in java. Finally we
can say that object are the encapsulated form of instance variable
and there associated methods.
The methods present in object are common for a set of object of
same type. So, methods are created a single copy for a set of
object, and they are linked with a set of instance variable. After
creating object .instance variable are distinct for all the object and
they are used to identify a particular object. In java four visibilities
are present to provide to access right of instance variable and
methods. The visibilities are as:-
2

Visibility

Default
Private Protected Public
/Friendly
1. Private àPrivate visibilities specify that this section can not be
access directly from the out side of the object but can be access from
any where of object. That means, private section can be access from
public, friendly and protected section of the object .So finally we can
say that private section is visible in a single object at a time. Private
section is not inheritable. That means function and variable present in
the private section

2. Default / Friendly àthe default visibility is friendly in java. The


default section can be access directly from the out side of the object.
That means the default section can be access in entire program of a
particular package (Collection of related class). Default section can be
inherited into the subclass. That means variable and function present in
the default section. Default section can be override and overwrite in the
subclass default section can contains instance variable as well as
methods.
3. Protected à The protected section can also be access directly
from the out side of the object. That means the protected is visible in
entire program in a particular package same as default. We know that
the default section can not be access in another package but protected
section can be access other package in subclass. protected section can
not be access in non subclass in other package protected section can
contains methods as well as instance variable protected can be inherit
into sub class and the method and instance variable can be overwrite
and override in the subclass . To protect overwriting and overriding the
final keyboard are used before the visibility of function and variable.

4. Public à The most visibility in java program is public. The public


visibility specifies that this section can be access from any where in
java programming. Public section can directly access from out side of
object. That means public section is visible in the entire program in a
3
particular package. Public section can also be visible in subclass as
well as in non subclass in other package. Public section can be
inheriting subclass and can be modified as the requirement of the user.
The common name of a set of
object is called class. It is also possible to say that class is the blue print
or logical design and imaginary design of object. Alternately we can
say that class is users define data type. Which is used to create new
data type by encapsulating standard data type or other user define data
type with there associated member function (methods) in a single unit
as the requirement of the user.

 A.P.I(Application program interface ).


 Encapsulation or Abstraction.
 Compiled and interpreted.
 Simple secured and robust.
 Platform independence.
 Generic programming.
 Class and object.
 Multithreading.
 Polymorphism.
 Distributed.
 Inheritance.
 Constructor.
 Exception.
 Applet.
 Package.
 Interface.
 Dynamic.
4

Class is an user define data type which is used to create new data
type as the requirement of the user by encapsulating different
standard data type or other user define data type in a single unit.
It is also possible to say that common name of set of object is
called class. alternately we can say that class is the blue print or
logical design of object in the encapsulated form of instance
variable and methods so in class methods and variable are present
with there appropriate type . In java 4 types of visibility are present
and they are applied in class in design time. It is also known to us
that the method are common for a set of object so all method
should be public.
1. Private àPrivate visibility specifies that this section can not
be access directly from the out side of the object but can be access
from any where of object. That means private section can be access
from public, friendly and protected section of the object .So finally
we can say that private section is visible in a single object at a
time. Private section is not inheritable. That means function and
variable present in the private section.
2. Deffoult/Friendelly àThe default visibility is friendly in
java. The default section can be access directly from the out side of
the object. That means the default section can be access in entire
program of a particular package (Collection of related class).
Default section can be inherited into the subclass. That means
variable and function present in the default section. Default section
can be override and overwrite in the subclass default section can
contains instance variable as well as methods.
3. Protected à The protected section can also be access directly
from the out side of the object. That means the protected is visible
in entire program in a particular package same as default. We
know that the default section can not be access in another package
but protected section can be access other package in subclass.
protected section can not be access in non subclass in other
package protected section can contains methods as well as instance
5
variable protected can be inherit into sub class and the method and
instance variable can be overwrite and override in the subclass . To
protect overwriting and overriding the final keyword are used
before the visibility of function and variable.

4. Public àThe most visibility in java program is public. The


public visibilities specify that this section can be access from any
where in java programming. Public section can directly access
from out side of object. That means public section is visible in the
entire program in a particular package public section can also be
visible in subclass as well as in non subclass in other package.
Public section can be Inherit in subclass and can be modified as the
requirement of the user. The common name of set of object is
called class. It is also possible to say that class is the blue print or
logical design and imaginary design of object. alternately be can
say that class is an user define data type to create new data type by
encapsulating standard data type or other user define data type
with there associated member function (methods) in a single unit
as there requirement of the user.
6

Encapsulation is a binding process by which instance variable are


bind with there associated method to create a complete object. We
know that method are common for a set of object and they are
created at the time of class declaration instance variable allocates
there memory at the time of object creation dynamically at the time
of execution after allocation of memory by the instance variable a
link between instance variable and there associated method. This
linking process is called Encapsulation or data binding. Which is
perform dynamically at the time of execution this type of binding
is called late binding or run time binding or execution time
binding.
The main purpose
of encapsulation is to create a single unit by binding different
instance variable and there function and extra cover is arise around
the component of the object and concurrently the internal
component are hidden from out side of the object. So we can say
that encapsulation implemented data binding by providing
appropriate access pacifiers to the component. Alternately we can
say that encapsulation is used to implement data abstraction by
hiding all components from out side of the object. Encapsulation
creates a single unit and the unit can move independently from one
location to another location.

One of the most important features of any programming language


is the reusability of code. Inheritance is process to implement the
concept reusability of code. In java three techniques are used to
implement the concept of reusability as:-

A.Function.
B.Inheritance.
C.Package.
Inheritance is a process by which we can create new classes using
existing sub class is called super class and the new class is called
base class. Alternately we can say that inheritance is a process to
implement the concept of parent child relationship that means in
7
java more than one super class can not be present for a single
subclass. That means more than one super class can not inherit into
a single subclass so multiple as well as hybrid inheritance can not
be implemented in java. The main purpose of is to reuse the
existing code present in super class in subclass the following
advantage are present in inheritance.

A. Using interface existing code can be reuse in subclass so using


the concept of inheritance programmers can develop large
program very easily.
B. Since code can be reuse in subclass productivity of programs is
increase.
C. If productivity is increase than the product cost will we decrease
as well as maintenance cost also is decrease.
D. If product cost and maintenance cost is minimum of a product
than the acceptability of the product will be maximum.

Types of inheritance-----

INHERETANCE

HERERICAL/TREE
SINGLE/SIMPLE MULTILEVEL STRUCTRE

1. Single or simple inheritance àsingle or simple inheritance


is those type of inheritance in which a single super class is used
to create single subclass. Inheritance visibility of component can
not be change in java graphically we can represent single/simple
inheritance as.
8

2. Multilevel inheritance àMultilevel inheritance is those


type of inheritance in which a sub class is used as a super class to
create another sub class .alternately we can say that multilevel
inheritance is the representation of single inheritance.
Graphically we can represent multilevel inheritance as.
9

CLASS A

CLASS B

CLASS C

3. Hierarchical/Tree structure inheritance à Hierarchical


or tree structure inheritance is those type of inheritance in which
every subclass has only one super class. But every super class can
be more than one sub class. graphically we can represent
heretical/ tree structure inheritance as-
10

B C D E

F G H I J K L M

In inheritance the concept of overwriting and overriding is arise if an


instance variable is inherit from super class to subclass than in subclass
new value can be supplied to the variable . the new overwrites the
executing value of the variable .in the variable the concept of
overwriting is implemented . If user wants to restrict the overwriting
than the final keyword is used before the general declaration of the
variable. The final variable can not can not be overwrite in the subclass .
That means final keyword create constant that values can not be changed
in subclass. Function present in subclass can be inherited into subclass
and new definition of the function can be created by the user in sub
classes. the new definition of the function of subclass overwrite the
executing definition of function in super class in subclass new definition
is active and in super class the old definition is user want to protect
function overwriting than the final keyword is used before the general
definition of the function . The final keyword can not restrict the
inheritance of the method and instance variable it only restrict only
overwriting and overriding.
11
If class is final
than class can not be inherit into subclass the final keyword protect the
extension of class in java subclass is the extension of the super class and
so final keyword restrict the extension.

Abstract classà Abstract class is that type of the class which has no
capacity to create object. Abstract class must be inherit into subclass to
create existence of the abstract class. Abstract class is used as a super
class in inheritance.

Abstract FunctionàAbstract function is that type of function which


has no definition or body, if a class contains an abstract function than the
class must be also an abstract.
12

The general meaning of polymorphism is single interface multiple task.


That means same thing different form. Poly means many and morph
means form. That means polymorphism is those type of programming
concept in which a particular function can take different form by taking
different number of argument and different types of argument and can
perform different task according to the form of the function. In java,
polymorphism is only implemented using the concept of function
overloading. There is no concept of operator overloading in JAVA. In
real life different task are performed using a single function by
supplying different arguments. to implement this concept in
programming language the concept of function overloading is arise. The
main purpose of polymorphism is to handle huge number of function.
Function overloading is those type of programming
system in which a particular function can take a different form by taking
different number of arguments and different types of argument and can
perform different task according to the form of the function. In JAVA
function overloading is implemented using dynamic binding. Function
overloading using early binding is not present using the concept of
simple methods. Function overloading using early binding can be
implemented in JAVA using the concept of static function.
We know that functions are
common for a set of object and they are allocate there respective
memory at the time of class declaration. In JAVA objects are created at
the time of execution using new operator. After that a binding process is
performed between instance variables and there associated functions.
This type of binding is called late binding or dynamic binding or run
time binding or execution time binding. In JAVA generally methods
are banded with instance variables using dynamic binding. So using
simple methods, function overloading can be implemented using
dynamic binding. Static function is called using the class name not the
object of the class and can perform any operation on any type of instance
variables using static function. Function overloading can also implement
using early binding.
13

JAVA programming language is platform independent. That means


JAVA program can be executed on any operating system and on any
computer with any internal architecture (configuration) provided the
word length of the computer must be greater than or equal to16 bit.
Platform independent indicates that the program is not dependent on the
operating system as well as internal architecture of the computers. JAVA
program is not dependent on operating system of the computer as well as
internal architecture of the computer system. But to execute the JAVA
program the internal configuration is a matter, because the word length
of the computer must be greater then or equal to 16 bit. Less then 16 bit
computer is not capable to execute the JAVA program. The main cause
of platform independent of JAVA programming language is the JVM
(Java Virtual Machine).
JVM
is an operating system over the actual operating system. JVM is
responsible to make compressibility of the actual operating system with
the JAVA program. JVM is interfacing between the actual operating
system and the JAVA program. The internal coding system of JVM is
Unicode, which is a 16 bit coding system. So the interact number of all
popular operating system is present in JVM, which can make a link with
the physical operating system.
JVM is divided in three parts

(1) JIT (Just In time Compiler)


(2) JAVA interpreter
(3) JAVA Run Time Environment
J AVA compiler is
known as just in time compiler because all programs are just in time
compiler because the entire program is not converted at a time to its
equivalent object code (byte code). We know that compiler compile a
program in to two phases. The first phase is known as analysis of
14
source program. In this phase only syntax errors are checked. If
syntax errors are present then appropriate error message is displayed.
The second phase is called synthesis of object program. In this phase
actual object code is created. But JAVA compiler, compile those
segment which is to be executed in the next cycling. JAVA compiler
is not compile system defined function because they are in compiled
form. That means JAVA compiler compile a particular segment at a
time which is to be executed in the next cycling. JAVA compiler
creates an intermediate code which is called byte code, written in
Unicode system. The intermediate byte code is interpreted by the
JAVA interpreter and creates appropriate object code understandable
by the physical operating system. The JAVA compiler is “javac” and
the JAVA interpreter is “java”. JAVA interpreter interprets byte code
to its equivalent object code and sent to the java run time environment
and the java run time environment sent the interpreted object code to
the operating system. Actually the operating system and the java
interpreter is interfaced using java runtime environment. The main
component present behind the platform independency is the java
runtime environment. In this component all the kernel information of
popular operating system are present at the time of installation. The
kernel information is activated in the java runtime environment which
is present in the internal operating system of the computer. The other
kernels are temporarily deactivated.
15

MULTITHREADING
Multithreading is those type of programming concept which is used to
implement the concept of multitasking. Thread means, small program
which can be executed at a time. Multithreading means more then one
smalls program which are executed simultaneously not concurrently
using small span of time and using the round robin scheduling. We know
that JVM is an operating system over the operating system, so in JVM a
scheduler is present which is responsible to implement multithreading.
In multithreading threads are different states :-
(1) New born state
(2) Ready state
(3) Running state
(4) Suspended state (temporarily)
(5) Terminated state or killed
In JAVA a thread class is present
which is used to implement the concept of multithreading. A run( )
function is present in the thread class which is used to run a thread. An
init( ) function is present, which is used to initialize a thread or new
born thread is created. Start( ) function is also present, which is used
to ready a thread to execute. Stop( ) function is present which is
responsible to terminate a thread. For temporarily suspended of thread
three functions are present and they are-
(1) Sleep
(2) Suspended
(3) Wait
The sleep( ) is automatically deactivated
after specific time given in millisecond in the sleep( ) function. The
suspended( ) function is deactivated when a resume( ) function is
called. Wait function is deactivated when a notify( ) is called.
16

Constructor is a special member function that’s name is same with class


name and that is automatically invoked at the time of object creation.
Construction has no return type even void. Construction can take
argument or can not be. Constructor can not be declared in the private
section of the class. But other visibility can be present with constructor.
That means, constructor can be public, protected or friendly but can not
be private. Constructor is divided in to two categories according to the
argument. If the constructor can not take any argument then the
constructor is called default constructor. If the constructor can take any
argument then it is called parameterized constructor. If a class contains a
parameterized constructor then the class should also contains a default
constructor. There is no concept of copy constructor in JAVA.
Constructor can not be inherit in the derived classes but can be invoked
from the sub-classes using the keyword “super”. If the super class
contains a default constructor then it is not necessary to present a
constructor in the sub-classes. If the super class contains a parameterized
constructor, then in the sub class minimum one constructor must be
present, to invoke the super class constructor. A single class can contain
more then one constructor. That means constructor can be overloaded.
There is no concept of destructor in
JAVA. The concept of garbage collection deletes all the variables and
functions of the program that’s execution is completed. So all the
instance variables are automatically initialized with there zero values at
the time of creation of the object, because the memory is cleared by the
garbage collection concept. If user wants to delete an object from the
memory then the finalize( ) function can be used to perform those type
of operation. That means, using finalize () function, particular object can
be deleted as the choice of the user but by the garbage collection all the
objects are deleted after execution of the program which is performed
automatically by the JVM.
17

Generic programming is those type of programming concept by which


we can create type independent code for all the type which maintains
same algorithms. In JAVA programming language large number of
generic classes is present to implement any type of concept. Generally
the generic classes are vector, stack, queue, array list, circular queue, B
tree etc. In JAVA the concept of generic functions is not present, only
the concept of generic classes is present. Using this class user can handle
any type of element as the requirement of the user.
For example :- array is a generic class to
handle any types of values using the concept of array. The array class
contains a large number of methods to handle array elements. The fill
function is used to store values into the array. The sor function is used to
arrange data elements in ascending or descending order. The delete
function is used to erase data elements from the array. Similarly the
search function is used to test existence of a particular element.
18

Exceptions are a type of error besides then the syntax error or logical
error as divide by zero. Alternately we can say that those types of error
which are not belonging to syntax error or logical error are called
EXCEPTION. Exceptions are divide in to two categories :-
(1) Synchronous or software related exception.
(2) Asynchronous or hardware related exception.
A synchronous type of exception is also
called software exception. Which are arise due to software limitation,
like arithmetic exception, input/output exception, number format
exception etc. synchronous exceptions can be smoothly handled by
JAVA programming language, because huge number system defined
exception classes are present. The popular exceptions classes are –
input/output exception, arithmetic exception, number format exception,
array index out of bound exceptions, string index out of bounds
exception, class not found exception, sql exception etc. using system
defined exception classes any type of exception can be handled besides
then the system defined exception. User can also create his own
exception classes to handle exceptions. In JAVA programming the
following tools are used to handle exceptions.
(1) Try ( )
(2) Catch ( )
(3) Throw ( ) /Throws ( )
The try block is used to identify
exception. After identifying the exception JAVA automatically throws
the exception to appropriate catch block, if the exceptions are system
defined exception. If the exceptions are user defined exceptions then the
throw statement is used to throw the exception to appropriate catch
block. A single function can contain more then one try block and
correspondingly more then one catch block. It is also possible to present
more then one catch block corresponding to a single try block.
Asynchronous exceptions are those types of
exceptions which are arises due to hardware failure, which can not be
handled by the JAVA programming language. Asynchronous exceptions
can not be handled by any programming language.
19

We know that methods are common for a set of object and instance
variables are distinct for every object. Methods are allocated their
memory at the time of class declaration and instance variables are
allocated their memory at the time of object creation. In JAVA
programming language objects are allocated their memory at the time of
execution using the new operator. After allocation of memory the
instance variables are binds with their associated methods at the time of
execution. This type of data binding is also called dynamic binding or
late binding or execution time binding or run time binding. In JAVA
object can not allocate their memory statically at the time of
compilation. They allocate their memory at the time of execution. So
only dynamic binding is present in JAVA. The concept of static binding
is partially implemented using the concept of static variables and static
function. Which are allocate their memory at the time of compilation
and can be executed without object. The concept of dynamic binding is
present in JAVA due to JAVA supports distributed processing. In
distributed processing a large program can be decomposed to its smaller
segments and distributed among all the processors which are connected

with the server or main computer.


20

Distributed processing is that type of processing in which more then one


processor are involved to execute a single program segment wise
concurrently. In distributed processing a large program is divided to its
independent smaller segment and processed by the processor, which are
connected with the main server. All the segments are executed
concurrently and at the end all the segments are combined and produce
the actual output on the main server. The processing speed is rapidly
increased due to the concept of distributed processing. To implement the
concept of distributed processing the system should be in network. In
JAVA programming language the distributed processing is
implemented. Using the concept of applet and RMI (Remote Method
Invocation) and using the concept of socket programming.
21

We know that JAVA programming language is the combined form of C


and C++. The syntax cal concept of JAVA is arising from the C
language. We know that the syntax of C programming language is very
simple. This simplicity of syntax is arising in the JAVA programming
language from the C language. The conceptual framework of JAVA is
arising from C++, which are very simple concept. So the JAVA
programming language is syntaxically and conceptually very simple.
JAVA programming
language provided high security to its data members and data values. We
know that JAVA is a pure object oriented programming language. So, all
the components must be present within class. We also know that classes
are always encapsulated, so objects are always encapsulated. A cover is
present around the components of objects, so any component can not be
directly accessed.
The visibility layer of JAVA programming like private,
friendly, protected etc provides security of the components. Inheritance
and the concept of the package also increase the security of instance
variables and methods. The applet programming can be executed on any
web browser and can not perform any operation on the terminal on
which it is executed. So, using the concept of applet information can be
propagated in the entire network with affecting the network.
User can developed any type of
application using JAVA programming language. So we can say that
JAVA is the most powerful programming language. JAVA language
also has the capability to access native programming languages C, C++
etc as the choice of the user.
22
The most important component of JAVA programming language is
JVM (Java Virtual Machine). JVM is divided in three components-
(1) Java Compiler
(2) Java Interpreter
(3) Java Runtime Environment
The JAVA compiler is responsible for to compile a source program to
its equivalent intermediate code byte code, which is written in 16 bit
coding system Unicode. The byte code is understandable by any
computer after interpreting to equivalent object code. The JAVA
compiler compiles a JAVA program using two phase. The first phase is
the analysis of source program in which syntax errors are checked. The
next phase is the synthesis of object program in which actual byte code
equivalent is generated. JAVA compiler not compiles the system defined
function, because they are in compiled form. The compiler is not
compiled the whole program at a time, if the program is very large and
divided by modules. Module by module compilation is performed by the
JAVA compiler. It is also called just in time (JIT) Compiler.
The next
phase of execution of JAVA program is interpretation of byte code
performed by JAVA interpreter (JAVA). The JAVA interpreter
interprets the byte code to its equivalent object code understandable by
the physical operating system and transfer to the JAVA run time
environment. That means JAVA program is executed in two phases-
(1) Compilation
(2) Interpretation
So JAVA is compiled and interpreted.

The full form of applet is application layout. Applet is stand alone


program which can be executed independently in any computer by
23
using any web-browser like hot java, internet explorer, MSN
messenger etc. applet program is stand alone program in which
main function is not present and can be propagated in the internet
automatically. System defined applet, class applet and j applet are
present in the package applet java and javax. Applet program can
not be created without the system defined class applet and j applet.
The classes must be inherit in the user class to create applet
program. The applet class generally contains the following popular
functions:-
(1) start
(2) init
(3) paint
(4) repaint
(5) destroy
The start( ) function start the execution of an
applet program which is automatically called. The init( ) function
initialize the applet to set the frame and visible the frame in the
applet viewer and applet window. The paint ( ) function actually
perform operation on the applet window as well as applet frame.
The repaint( ) function is used to called the paint function again.
The destroy( ) function kills the applet and stop viewing.
Applet is divided in two categories according to the storage
or location of the applet:-
(1) Local applet
(2) Remote applet
Local applets are those types of applets
which are stored in the same computer on which they are executing.
If the system is stand alone, system can not connected in the
network. User can create only local applet on that computer. Remote
applets are those types of applets which are stored in the server and
executing in any computer connected with the server. Generally
websites are contains remote applet.

JAVA programming language is basically used to design the


interface. JAVA is generally used as a front end program (software)
in application development. JAVA programming language has the
24
capability to interact with any DBMS or RDBMS. To store data
values using the security layers of the DBMS. JAVA programming
language has no such powerful capability to store data values in the
files with maximum security. JAVA data file can be opened and
modified by any user very easily but we know that in DBMS as well
as RDBMS provides high security to the database using user name,
password, privilege and rolls. So JAVA programmers are generally
stored data values in data bases in the RDBMS, using the JAVA
application program interface (A.P.I) JDBC (Java database
connection).using JDBC user can access and RDBMS and DBMS
such as oracle, SQL server, MS access, Visual FoxPro etc as the
choice of the user by selecting appropriate driver and set a
connection with the databases. That means, JAVA API (Application
Program interface) programs are present to interact with other
programming languages as the choice of the user.

One of the most important features of any programming language is to


implement the concept of object re-use ability. In JAVA programming
language has the capability to re-use existing code in other programs or
in same programs. If an existing code is to be re-used in other program
then the concept of package is arise. Package is the collection of related
classes which is used to re-use existing code in other programs. JAVA
programming language has huge number system defined packages.
25
Which are contains system defined functions in appropriate classes. In
JAVA programming language, near about 162 System defined package
are present and near about 18000 System defined functions are present.
The most
popular System defined packages are applet, lang, util, swing, net,
javax, awt etc. User can create his own package as the choice of the
user. Package generally contains public classes otherwise the class can
not visible in other program. The package statement must be the first
statement in the any user program. After that any statement can be
present. User must be create a subdirectory as same as the package name
and the program must be in the subdirectory with the name of the public
.
class name with (Dot) java extension. The class file of the program
must be saved under the subdirectory. The package can be import in the
super directory only. So, program in which the package is re-used should
be created in the super directory of the package directory. At a time only
one public class can be stored in a package. If the class is not public then
it can not be import in the user program. Non public classes are hidden
from the user program and they can not be accessed in the user program.

In JAVA programming language the concept of multiple inheritance is


not present because more then one sub class can not be inherit at a time
in a single sub class but more then one interface can be inherit in to a
single sub class. That means using interface the concept of multiple
inheritance can be implemented.
Interface is also is an user defined data
type as same as class. In which only constant value and abstract
functions can be present. In interface the default visibility is public.
Interface can contains function but all the functions are abstract by
default. Functions present in the interface must be redefined in the sub
classes otherwise error will arise. Data member present in the interface
26
are by default static final. That means, only constant value can be
present in interface. We can not change the data members in the sub
classes of the interface. An interface can be inherit in to another
interface using the keyword extends but more then one interface can not
be inherit to a single interface at a time. An interface can be inherit in to
a sub class using the keyword implements. More then one interface can
be inherit in to a sub class at a time. A system defined package event
under awt package is present which contains all the system defined
interfaces as ActionListener, KeyListener, MouseListener,
mousewheelListener, ItemListener, Componentlistener,
WindowsListener etc.

You might also like